@aimee.shop/sdk 0.0.1 → 0.1.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/LICENSE +1 -1
- package/README.md +9 -9
- package/dist/browser/browser-auth.d.ts +1 -1
- package/dist/browser/browser-auth.js +2 -2
- package/dist/browser/index.d.ts +12 -12
- package/dist/browser/index.js +12 -12
- package/dist/core/auth/auth-chain.js +2 -2
- package/dist/core/auth/interactive.authenticator.js +1 -1
- package/dist/core/canonical-hosts.d.ts +12 -0
- package/dist/core/canonical-hosts.d.ts.map +1 -0
- package/dist/core/canonical-hosts.js +11 -0
- package/dist/core/canonical-hosts.js.map +1 -0
- package/dist/core/config.d.ts +9 -9
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +36 -40
- package/dist/core/config.js.map +1 -1
- package/dist/core/errors/index.d.ts +11 -11
- package/dist/core/errors/index.js +11 -11
- package/dist/core/events/event-envelope.d.ts +1 -1
- package/dist/core/events/event-names.d.ts +1 -1
- package/dist/core/events/event-names.js +1 -1
- package/dist/core/http-client.d.ts +3 -3
- package/dist/core/http-client.d.ts.map +1 -1
- package/dist/core/http-client.js +56 -13
- package/dist/core/http-client.js.map +1 -1
- package/dist/core/retry.d.ts +3 -3
- package/dist/core/sdk.d.ts +11 -11
- package/dist/core/sdk.js +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/services/core/assets.client.d.ts.map +1 -1
- package/dist/services/core/assets.client.js.map +1 -1
- package/dist/services/core/cart-messages/types.d.ts +1 -1
- package/dist/services/core/checkout.client.d.ts +1 -1
- package/dist/services/core/checkout.client.js +1 -1
- package/dist/services/core/cms/types.d.ts.map +1 -1
- package/dist/services/core/cms/types.js.map +1 -1
- package/dist/services/core/inventory/inventory.client.d.ts +6 -3
- package/dist/services/core/inventory/inventory.client.d.ts.map +1 -1
- package/dist/services/core/inventory/inventory.client.js +4 -1
- package/dist/services/core/inventory/inventory.client.js.map +1 -1
- package/dist/services/core/inventory/types.d.ts +21 -5
- package/dist/services/core/inventory/types.d.ts.map +1 -1
- package/dist/services/core/orders.client.d.ts +40 -0
- package/dist/services/core/orders.client.d.ts.map +1 -1
- package/dist/services/core/orders.client.js +8 -0
- package/dist/services/core/orders.client.js.map +1 -1
- package/dist/services/core/products.client.d.ts +25 -0
- package/dist/services/core/products.client.d.ts.map +1 -1
- package/dist/services/core/products.client.js +8 -0
- package/dist/services/core/products.client.js.map +1 -1
- package/dist/services/core/shipping/types.d.ts.map +1 -1
- package/dist/storefront/index.d.ts +22 -10
- package/dist/storefront/index.d.ts.map +1 -1
- package/dist/storefront/index.js +30 -9
- package/dist/storefront/index.js.map +1 -1
- package/package.json +5 -5
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -13,10 +13,10 @@ npm install @aimee.shop/sdk
|
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
-
import {
|
|
16
|
+
import { AimeeSDK } from '@aimee.shop/sdk';
|
|
17
17
|
|
|
18
|
-
const sdk = new
|
|
19
|
-
apiKey: process.env.
|
|
18
|
+
const sdk = new AimeeSDK({
|
|
19
|
+
apiKey: process.env.AIMEE_API_KEY,
|
|
20
20
|
tenantId: 'tenant-uuid',
|
|
21
21
|
});
|
|
22
22
|
|
|
@@ -27,10 +27,10 @@ const checkout = await sdk.checkout.create({ cartId: 'cart-uuid' });
|
|
|
27
27
|
Browser usage:
|
|
28
28
|
|
|
29
29
|
```typescript
|
|
30
|
-
import {
|
|
30
|
+
import { aimee, browserAuth } from '@aimee.shop/sdk/browser';
|
|
31
31
|
|
|
32
32
|
await browserAuth.signIn('user@example.com', 'password');
|
|
33
|
-
const products = await
|
|
33
|
+
const products = await aimee.products.list();
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
### `@aimee.shop/sdk-platform`
|
|
@@ -42,10 +42,10 @@ npm install @aimee.shop/sdk @aimee.shop/sdk-platform
|
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
```typescript
|
|
45
|
-
import {
|
|
45
|
+
import { AimeePlatformSDK } from '@aimee.shop/sdk-platform';
|
|
46
46
|
|
|
47
|
-
const sdk = new
|
|
48
|
-
apiKey: process.env.
|
|
47
|
+
const sdk = new AimeePlatformSDK({
|
|
48
|
+
apiKey: process.env.AIMEE_API_KEY,
|
|
49
49
|
tenantId: 'tenant-uuid',
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -81,7 +81,7 @@ Supported auth modes:
|
|
|
81
81
|
- Interactive auth for local development.
|
|
82
82
|
|
|
83
83
|
```typescript
|
|
84
|
-
const sdk = new
|
|
84
|
+
const sdk = new AimeeSDK({
|
|
85
85
|
getAccessToken: () => authContext.getToken(),
|
|
86
86
|
tenantId: 'tenant-uuid',
|
|
87
87
|
});
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Auto-detects and manages Cognito session from localStorage.
|
|
4
4
|
*
|
|
5
5
|
* Uses COGNITO_CONFIG resolved from environment variables at runtime.
|
|
6
|
-
* Set
|
|
6
|
+
* Set AIMEE_COGNITO_USER_POOL_ID and AIMEE_COGNITO_CLIENT_ID (or NEXT_PUBLIC_ variants).
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Auto-detects and manages Cognito session from localStorage.
|
|
4
4
|
*
|
|
5
5
|
* Uses COGNITO_CONFIG resolved from environment variables at runtime.
|
|
6
|
-
* Set
|
|
6
|
+
* Set AIMEE_COGNITO_USER_POOL_ID and AIMEE_COGNITO_CLIENT_ID (or NEXT_PUBLIC_ variants).
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```typescript
|
|
@@ -38,7 +38,7 @@ export class BrowserAuth {
|
|
|
38
38
|
// Check for browser environment
|
|
39
39
|
if (typeof window === 'undefined') {
|
|
40
40
|
throw new Error('BrowserAuth can only be used in browser environments. ' +
|
|
41
|
-
'For server-side usage, use
|
|
41
|
+
'For server-side usage, use AimeeSDK with apiKey instead.');
|
|
42
42
|
}
|
|
43
43
|
// Validate Cognito config is available (resolved from env vars or defaults)
|
|
44
44
|
if (!COGNITO_CONFIG.userPoolId || !COGNITO_CONFIG.clientId) {
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
9
|
* // Simple, Stripe-like usage!
|
|
10
|
-
* import {
|
|
10
|
+
* import { aimee } from '@aimee.shop/sdk/browser';
|
|
11
11
|
*
|
|
12
12
|
* // Just works - auth auto-detected from Cognito session
|
|
13
|
-
* const products = await
|
|
14
|
-
* const orders = await
|
|
13
|
+
* const products = await aimee.products.list();
|
|
14
|
+
* const orders = await aimee.orders.list();
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
19
|
* // Sign in and use
|
|
20
|
-
* import {
|
|
20
|
+
* import { aimee, browserAuth } from '@aimee.shop/sdk/browser';
|
|
21
21
|
*
|
|
22
22
|
* await browserAuth.signIn('admin@example.com', 'password');
|
|
23
|
-
* const products = await
|
|
23
|
+
* const products = await aimee.products.list();
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*
|
|
35
35
|
* @packageDocumentation
|
|
36
36
|
*/
|
|
37
|
-
import {
|
|
37
|
+
import { AimeeSDK } from '../core/sdk.js';
|
|
38
38
|
import { browserAuth, BrowserAuth, BrowserUser, SignInResult, SignInOptions, CognitoAuthFlow } from './browser-auth.js';
|
|
39
39
|
/**
|
|
40
40
|
* Pre-configured SDK instance with auto-detected browser Cognito auth.
|
|
@@ -43,20 +43,20 @@ import { browserAuth, BrowserAuth, BrowserUser, SignInResult, SignInOptions, Cog
|
|
|
43
43
|
* - Detects Cognito session from localStorage
|
|
44
44
|
* - Injects ID token into all API requests
|
|
45
45
|
*
|
|
46
|
-
* For server-side usage, use `
|
|
46
|
+
* For server-side usage, use `AimeeSDK` with `apiKey` instead.
|
|
47
47
|
*
|
|
48
48
|
* @example
|
|
49
49
|
* ```typescript
|
|
50
|
-
* import {
|
|
50
|
+
* import { aimee } from '@aimee.shop/sdk/browser';
|
|
51
51
|
*
|
|
52
52
|
* // No setup needed - just use it!
|
|
53
|
-
* const products = await
|
|
53
|
+
* const products = await aimee.products.list();
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
export declare const
|
|
56
|
+
export declare const aimee: AimeeSDK;
|
|
57
57
|
export { browserAuth };
|
|
58
58
|
export type { BrowserAuth, BrowserUser, SignInResult, SignInOptions, CognitoAuthFlow };
|
|
59
|
-
export {
|
|
60
|
-
export type {
|
|
59
|
+
export { AimeeSDK };
|
|
60
|
+
export type { AimeeSDKConfig, ServiceEndpoints, CognitoConfig } from '../core/config.js';
|
|
61
61
|
export { COGNITO_CONFIG } from '../core/config.js';
|
|
62
62
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/browser/index.js
CHANGED
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
* @example
|
|
8
8
|
* ```typescript
|
|
9
9
|
* // Simple, Stripe-like usage!
|
|
10
|
-
* import {
|
|
10
|
+
* import { aimee } from '@aimee.shop/sdk/browser';
|
|
11
11
|
*
|
|
12
12
|
* // Just works - auth auto-detected from Cognito session
|
|
13
|
-
* const products = await
|
|
14
|
-
* const orders = await
|
|
13
|
+
* const products = await aimee.products.list();
|
|
14
|
+
* const orders = await aimee.orders.list();
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
19
|
* // Sign in and use
|
|
20
|
-
* import {
|
|
20
|
+
* import { aimee, browserAuth } from '@aimee.shop/sdk/browser';
|
|
21
21
|
*
|
|
22
22
|
* await browserAuth.signIn('admin@example.com', 'password');
|
|
23
|
-
* const products = await
|
|
23
|
+
* const products = await aimee.products.list();
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
26
|
* @example
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
*
|
|
35
35
|
* @packageDocumentation
|
|
36
36
|
*/
|
|
37
|
-
import {
|
|
37
|
+
import { AimeeSDK } from '../core/sdk.js';
|
|
38
38
|
import { browserAuth, } from './browser-auth.js';
|
|
39
39
|
/**
|
|
40
40
|
* Pre-configured SDK instance with auto-detected browser Cognito auth.
|
|
@@ -43,18 +43,18 @@ import { browserAuth, } from './browser-auth.js';
|
|
|
43
43
|
* - Detects Cognito session from localStorage
|
|
44
44
|
* - Injects ID token into all API requests
|
|
45
45
|
*
|
|
46
|
-
* For server-side usage, use `
|
|
46
|
+
* For server-side usage, use `AimeeSDK` with `apiKey` instead.
|
|
47
47
|
*
|
|
48
48
|
* @example
|
|
49
49
|
* ```typescript
|
|
50
|
-
* import {
|
|
50
|
+
* import { aimee } from '@aimee.shop/sdk/browser';
|
|
51
51
|
*
|
|
52
52
|
* // No setup needed - just use it!
|
|
53
|
-
* const products = await
|
|
53
|
+
* const products = await aimee.products.list();
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
export const
|
|
57
|
-
// Auto-inject Cognito ID token (backend @
|
|
56
|
+
export const aimee = new AimeeSDK({
|
|
57
|
+
// Auto-inject Cognito ID token (backend @aimee/auth expects tokenUse: 'id')
|
|
58
58
|
getAccessToken: () => browserAuth.getIdToken(),
|
|
59
59
|
// Debug mode follows NODE_ENV
|
|
60
60
|
debug: process.env.NODE_ENV === 'development',
|
|
@@ -62,7 +62,7 @@ export const ziftr = new ZiftrSDK({
|
|
|
62
62
|
// Re-export auth helper for login/logout
|
|
63
63
|
export { browserAuth };
|
|
64
64
|
// Re-export main SDK class and types (for advanced usage)
|
|
65
|
-
export {
|
|
65
|
+
export { AimeeSDK };
|
|
66
66
|
// Re-export Cognito config for frontends that manage their own auth
|
|
67
67
|
// but want to use the SDK's baked-in configuration
|
|
68
68
|
export { COGNITO_CONFIG } from '../core/config.js';
|
|
@@ -45,8 +45,8 @@ export class AuthChain {
|
|
|
45
45
|
' - apiKey: Pass an API key in config\n' +
|
|
46
46
|
' - email/password: Pass Cognito credentials in config\n' +
|
|
47
47
|
' - getAccessToken: Pass a token getter for browser auth\n' +
|
|
48
|
-
' -
|
|
49
|
-
' -
|
|
48
|
+
' - AIMEE_API_KEY: Set environment variable\n' +
|
|
49
|
+
' - AIMEE_EMAIL/AIMEE_PASSWORD: Set environment variables\n' +
|
|
50
50
|
'\nIf using browser auth, ensure the user is logged in.');
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
@@ -107,7 +107,7 @@ export class InteractiveAuthenticator {
|
|
|
107
107
|
});
|
|
108
108
|
};
|
|
109
109
|
try {
|
|
110
|
-
console.log('\n🔐
|
|
110
|
+
console.log('\n🔐 Aimee SDK Authentication\n');
|
|
111
111
|
const email = await question('Email: ');
|
|
112
112
|
if (!email) {
|
|
113
113
|
throw new AuthenticationError('Email is required');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Cloudflare gateway origins (no /v1). Safe for the storefront
|
|
3
|
+
* browser graph: this module must never read process.env or import config.ts.
|
|
4
|
+
*/
|
|
5
|
+
export declare const CANONICAL_API_HOSTS: {
|
|
6
|
+
readonly local: "http://localhost:3000";
|
|
7
|
+
readonly dev: "https://api-dev.aimee.shop";
|
|
8
|
+
readonly staging: "https://api-staging.aimee.shop";
|
|
9
|
+
readonly production: "https://api.aimee.shop";
|
|
10
|
+
};
|
|
11
|
+
export type CanonicalApiEnvironment = keyof typeof CANONICAL_API_HOSTS;
|
|
12
|
+
//# sourceMappingURL=canonical-hosts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-hosts.d.ts","sourceRoot":"","sources":["../../../../src/core/canonical-hosts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,MAAM,OAAO,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Cloudflare gateway origins (no /v1). Safe for the storefront
|
|
3
|
+
* browser graph: this module must never read process.env or import config.ts.
|
|
4
|
+
*/
|
|
5
|
+
export const CANONICAL_API_HOSTS = {
|
|
6
|
+
local: 'http://localhost:3000',
|
|
7
|
+
dev: 'https://api-dev.aimee.shop',
|
|
8
|
+
staging: 'https://api-staging.aimee.shop',
|
|
9
|
+
production: 'https://api.aimee.shop',
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=canonical-hosts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-hosts.js","sourceRoot":"","sources":["../../../../src/core/canonical-hosts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,uBAAuB;IAC9B,GAAG,EAAE,4BAA4B;IACjC,OAAO,EAAE,gCAAgC;IACzC,UAAU,EAAE,wBAAwB;CAC5B,CAAC"}
|
package/dist/core/config.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AimeeError } from './errors/index.js';
|
|
3
3
|
import type { RetryOptions } from './retry.js';
|
|
4
|
-
export type
|
|
4
|
+
export type AimeeEnvironment = 'local' | 'dev' | 'staging' | 'production';
|
|
5
5
|
/**
|
|
6
|
-
* Configuration options for the
|
|
6
|
+
* Configuration options for the Aimee SDK
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface AimeeSDKConfig {
|
|
9
9
|
apiKey?: string;
|
|
10
10
|
email?: string;
|
|
11
11
|
password?: string;
|
|
@@ -16,7 +16,7 @@ export interface ZiftrSDKConfig {
|
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
|
-
* const sdk = new
|
|
19
|
+
* const sdk = new AimeeSDK({
|
|
20
20
|
* getAccessToken: () => authContext.getToken(),
|
|
21
21
|
* });
|
|
22
22
|
* ```
|
|
@@ -24,7 +24,7 @@ export interface ZiftrSDKConfig {
|
|
|
24
24
|
getAccessToken?: () => Promise<string | null>;
|
|
25
25
|
tenantId?: string;
|
|
26
26
|
storeId?: string;
|
|
27
|
-
environment?:
|
|
27
|
+
environment?: AimeeEnvironment;
|
|
28
28
|
coreApiUrl?: string;
|
|
29
29
|
rbacApiUrl?: string;
|
|
30
30
|
paymentsApiUrl?: string;
|
|
@@ -37,7 +37,7 @@ export interface ZiftrSDKConfig {
|
|
|
37
37
|
retry?: RetryOptions;
|
|
38
38
|
onRequest?: (config: AxiosRequestConfig) => AxiosRequestConfig | Promise<AxiosRequestConfig>;
|
|
39
39
|
onResponse?: <T>(response: T) => T | Promise<T>;
|
|
40
|
-
onError?: (error:
|
|
40
|
+
onError?: (error: AimeeError) => void | Promise<void>;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Service endpoint URLs
|
|
@@ -50,7 +50,7 @@ export interface ServiceEndpoints {
|
|
|
50
50
|
notificationsApi: string;
|
|
51
51
|
aiApi: string;
|
|
52
52
|
}
|
|
53
|
-
export declare const ENVIRONMENT_ENDPOINTS: Record<
|
|
53
|
+
export declare const ENVIRONMENT_ENDPOINTS: Record<AimeeEnvironment, ServiceEndpoints>;
|
|
54
54
|
/**
|
|
55
55
|
* Cognito configuration per environment
|
|
56
56
|
*/
|
|
@@ -67,6 +67,6 @@ export declare const DEFAULT_CONFIG: {
|
|
|
67
67
|
readonly debug: false;
|
|
68
68
|
readonly interactive: false;
|
|
69
69
|
};
|
|
70
|
-
export declare function detectEnvironment():
|
|
70
|
+
export declare function detectEnvironment(): AimeeEnvironment;
|
|
71
71
|
export declare const COGNITO_CONFIG: CognitoConfig;
|
|
72
72
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG,YAAY,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,cAAc;IAE7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAG9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAG/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,YAAY,CAAC;IAGrB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC7F,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AA6ED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAK5E,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAqBD;;GAEG;AACH,eAAO,MAAM,cAAc;;;;CAIjB,CAAC;AAQX,wBAAgB,iBAAiB,IAAI,gBAAgB,CAKpD;AAED,eAAO,MAAM,cAAc,EAAE,aAAgC,CAAC"}
|
package/dist/core/config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CANONICAL_API_HOSTS } from './canonical-hosts.js';
|
|
1
2
|
/**
|
|
2
3
|
* Static map of NEXT_PUBLIC_ env var references.
|
|
3
4
|
* Next.js replaces process.env.NEXT_PUBLIC_* at compile time using static
|
|
@@ -8,26 +9,26 @@ function getNextPublicEnv(name) {
|
|
|
8
9
|
if (typeof process === 'undefined' || !process.env)
|
|
9
10
|
return undefined;
|
|
10
11
|
switch (name) {
|
|
11
|
-
case '
|
|
12
|
-
return process.env.
|
|
13
|
-
case '
|
|
14
|
-
return process.env.
|
|
15
|
-
case '
|
|
16
|
-
return process.env.
|
|
17
|
-
case '
|
|
18
|
-
return process.env.
|
|
19
|
-
case '
|
|
20
|
-
return process.env.
|
|
21
|
-
case '
|
|
22
|
-
return process.env.
|
|
23
|
-
case '
|
|
24
|
-
return process.env.
|
|
25
|
-
case '
|
|
26
|
-
return process.env.
|
|
27
|
-
case '
|
|
28
|
-
return process.env.
|
|
29
|
-
case '
|
|
30
|
-
return process.env.
|
|
12
|
+
case 'AIMEE_CORE_API_URL':
|
|
13
|
+
return process.env.NEXT_PUBLIC_AIMEE_CORE_API_URL;
|
|
14
|
+
case 'AIMEE_RBAC_API_URL':
|
|
15
|
+
return process.env.NEXT_PUBLIC_AIMEE_RBAC_API_URL;
|
|
16
|
+
case 'AIMEE_PAYMENTS_API_URL':
|
|
17
|
+
return process.env.NEXT_PUBLIC_AIMEE_PAYMENTS_API_URL;
|
|
18
|
+
case 'AIMEE_WORKFLOWS_API_URL':
|
|
19
|
+
return process.env.NEXT_PUBLIC_AIMEE_WORKFLOWS_API_URL;
|
|
20
|
+
case 'AIMEE_NOTIFICATIONS_API_URL':
|
|
21
|
+
return process.env.NEXT_PUBLIC_AIMEE_NOTIFICATIONS_API_URL;
|
|
22
|
+
case 'AIMEE_AI_API_URL':
|
|
23
|
+
return process.env.NEXT_PUBLIC_AIMEE_AI_API_URL;
|
|
24
|
+
case 'AIMEE_COGNITO_USER_POOL_ID':
|
|
25
|
+
return process.env.NEXT_PUBLIC_AIMEE_COGNITO_USER_POOL_ID;
|
|
26
|
+
case 'AIMEE_COGNITO_CLIENT_ID':
|
|
27
|
+
return process.env.NEXT_PUBLIC_AIMEE_COGNITO_CLIENT_ID;
|
|
28
|
+
case 'AIMEE_COGNITO_REGION':
|
|
29
|
+
return process.env.NEXT_PUBLIC_AIMEE_COGNITO_REGION;
|
|
30
|
+
case 'AIMEE_ENV':
|
|
31
|
+
return process.env.NEXT_PUBLIC_AIMEE_ENV;
|
|
31
32
|
default:
|
|
32
33
|
return undefined;
|
|
33
34
|
}
|
|
@@ -52,24 +53,19 @@ function gatewayEndpoints(baseUrl) {
|
|
|
52
53
|
}
|
|
53
54
|
// Canonical Cloudflare edge hosts per environment (see api-routing-standard.md).
|
|
54
55
|
// Each host is the bare gateway origin with NO /v1 -- clients append /v1/<service>.
|
|
55
|
-
const CANONICAL_HOSTS =
|
|
56
|
-
|
|
57
|
-
dev: 'https://api-dev.ziftr.ai',
|
|
58
|
-
staging: 'https://api-staging.ziftr.ai',
|
|
59
|
-
production: 'https://api.ziftr.com',
|
|
60
|
-
};
|
|
61
|
-
// Per-service precedence: ZIFTR_<SERVICE>_API_URL > ZIFTR_CORE_API_URL > canonical host.
|
|
56
|
+
const CANONICAL_HOSTS = CANONICAL_API_HOSTS;
|
|
57
|
+
// Per-service precedence: AIMEE_<SERVICE>_API_URL > AIMEE_CORE_API_URL > canonical host.
|
|
62
58
|
// Locally, non-core services fall back to localhost:3000 and expect a per-service override
|
|
63
|
-
// (e.g.
|
|
59
|
+
// (e.g. AIMEE_RBAC_API_URL=http://localhost:3001) for direct-to-service access.
|
|
64
60
|
function resolveEndpoints(env) {
|
|
65
|
-
const base = getEnv('
|
|
61
|
+
const base = getEnv('AIMEE_CORE_API_URL') ?? CANONICAL_HOSTS[env];
|
|
66
62
|
return {
|
|
67
63
|
...gatewayEndpoints(base),
|
|
68
|
-
rbacApi: getEnv('
|
|
69
|
-
paymentsApi: getEnv('
|
|
70
|
-
workflowsApi: getEnv('
|
|
71
|
-
notificationsApi: getEnv('
|
|
72
|
-
aiApi: getEnv('
|
|
64
|
+
rbacApi: getEnv('AIMEE_RBAC_API_URL') ?? base,
|
|
65
|
+
paymentsApi: getEnv('AIMEE_PAYMENTS_API_URL') ?? base,
|
|
66
|
+
workflowsApi: getEnv('AIMEE_WORKFLOWS_API_URL') ?? base,
|
|
67
|
+
notificationsApi: getEnv('AIMEE_NOTIFICATIONS_API_URL') ?? base,
|
|
68
|
+
aiApi: getEnv('AIMEE_AI_API_URL') ?? base,
|
|
73
69
|
};
|
|
74
70
|
}
|
|
75
71
|
// Each environment maps to a canonical gateway host; env vars override per service.
|
|
@@ -85,13 +81,13 @@ const PROD_COGNITO = {
|
|
|
85
81
|
region: 'us-east-2',
|
|
86
82
|
};
|
|
87
83
|
function resolveCognito() {
|
|
88
|
-
const userPoolId = getEnv('
|
|
89
|
-
const clientId = getEnv('
|
|
84
|
+
const userPoolId = getEnv('AIMEE_COGNITO_USER_POOL_ID');
|
|
85
|
+
const clientId = getEnv('AIMEE_COGNITO_CLIENT_ID');
|
|
90
86
|
if (userPoolId && clientId) {
|
|
91
87
|
return {
|
|
92
88
|
userPoolId,
|
|
93
89
|
clientId,
|
|
94
|
-
region: getEnv('
|
|
90
|
+
region: getEnv('AIMEE_COGNITO_REGION') ?? 'us-east-2',
|
|
95
91
|
};
|
|
96
92
|
}
|
|
97
93
|
return PROD_COGNITO;
|
|
@@ -105,12 +101,12 @@ export const DEFAULT_CONFIG = {
|
|
|
105
101
|
interactive: false,
|
|
106
102
|
};
|
|
107
103
|
const VALID_ENVIRONMENTS = ['local', 'dev', 'staging', 'production'];
|
|
108
|
-
function
|
|
104
|
+
function isAimeeEnvironment(env) {
|
|
109
105
|
return VALID_ENVIRONMENTS.some((validEnvironment) => validEnvironment === env);
|
|
110
106
|
}
|
|
111
107
|
export function detectEnvironment() {
|
|
112
|
-
const env = getEnv('
|
|
113
|
-
if (env &&
|
|
108
|
+
const env = getEnv('AIMEE_ENV');
|
|
109
|
+
if (env && isAimeeEnvironment(env))
|
|
114
110
|
return env;
|
|
115
111
|
if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development')
|
|
116
112
|
return 'local';
|
package/dist/core/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/core/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"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WAAW;CACpB,CAAC;AAEF,SAAS,cAAc;IACrB,MAAM,UAAU,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;IACnD,IAAI,UAAU,IAAI,QAAQ,EAAE,CAAC;QAC3B,OAAO;YACL,UAAU;YACV,QAAQ;YACR,MAAM,EAAE,MAAM,CAAC,sBAAsB,CAAC,IAAI,WAAW;SACtD,CAAC;IACJ,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,KAAK;CACV,CAAC;AAEX,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,CAA8B,CAAC;AAElG,SAAS,kBAAkB,CAAC,GAAW;IACrC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,KAAK,GAAG,CAAC,CAAC;AACjF,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IAChC,IAAI,GAAG,IAAI,kBAAkB,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAC/C,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,QAAQ,KAAK,aAAa;QAAE,OAAO,OAAO,CAAC;IAC9F,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAkB,cAAc,EAAE,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Base error class for all
|
|
2
|
+
* Base error class for all Aimee SDK errors.
|
|
3
3
|
* Provides consistent error structure with code, statusCode, and JSON serialization.
|
|
4
4
|
*/
|
|
5
|
-
export declare abstract class
|
|
5
|
+
export declare abstract class AimeeError extends Error {
|
|
6
6
|
abstract readonly code: string;
|
|
7
7
|
abstract readonly statusCode: number;
|
|
8
8
|
constructor(message: string);
|
|
@@ -12,7 +12,7 @@ export declare abstract class ZiftrError extends Error {
|
|
|
12
12
|
* Thrown when authentication fails (401).
|
|
13
13
|
* Examples: Invalid API key, expired token, missing credentials.
|
|
14
14
|
*/
|
|
15
|
-
export declare class AuthenticationError extends
|
|
15
|
+
export declare class AuthenticationError extends AimeeError {
|
|
16
16
|
readonly code = "AUTHENTICATION_ERROR";
|
|
17
17
|
readonly statusCode = 401;
|
|
18
18
|
}
|
|
@@ -20,7 +20,7 @@ export declare class AuthenticationError extends ZiftrError {
|
|
|
20
20
|
* Thrown when authorization fails (403).
|
|
21
21
|
* Examples: Insufficient permissions, wrong tenant context.
|
|
22
22
|
*/
|
|
23
|
-
export declare class AuthorizationError extends
|
|
23
|
+
export declare class AuthorizationError extends AimeeError {
|
|
24
24
|
readonly code = "AUTHORIZATION_ERROR";
|
|
25
25
|
readonly statusCode = 403;
|
|
26
26
|
}
|
|
@@ -36,7 +36,7 @@ export interface FieldError {
|
|
|
36
36
|
* Thrown when request validation fails (400).
|
|
37
37
|
* Includes field-level errors for form handling.
|
|
38
38
|
*/
|
|
39
|
-
export declare class ValidationError extends
|
|
39
|
+
export declare class ValidationError extends AimeeError {
|
|
40
40
|
readonly code = "VALIDATION_ERROR";
|
|
41
41
|
readonly statusCode = 400;
|
|
42
42
|
readonly errors: FieldError[];
|
|
@@ -46,7 +46,7 @@ export declare class ValidationError extends ZiftrError {
|
|
|
46
46
|
/**
|
|
47
47
|
* Thrown when a resource is not found (404).
|
|
48
48
|
*/
|
|
49
|
-
export declare class NotFoundError extends
|
|
49
|
+
export declare class NotFoundError extends AimeeError {
|
|
50
50
|
readonly code = "NOT_FOUND";
|
|
51
51
|
readonly statusCode = 404;
|
|
52
52
|
}
|
|
@@ -54,7 +54,7 @@ export declare class NotFoundError extends ZiftrError {
|
|
|
54
54
|
* Thrown when a request conflicts with current resource state (409).
|
|
55
55
|
* Examples: stale navigation revision (If-Match / expectedRevision mismatch).
|
|
56
56
|
*/
|
|
57
|
-
export declare class ConflictError extends
|
|
57
|
+
export declare class ConflictError extends AimeeError {
|
|
58
58
|
readonly code = "CONFLICT";
|
|
59
59
|
readonly statusCode = 409;
|
|
60
60
|
}
|
|
@@ -63,7 +63,7 @@ export declare class ConflictError extends ZiftrError {
|
|
|
63
63
|
* Examples: public getNavigation with a matching If-None-Match ETag.
|
|
64
64
|
* This is a cache hit, not a failure -- catch it instead of treating as ApiError.
|
|
65
65
|
*/
|
|
66
|
-
export declare class NotModifiedError extends
|
|
66
|
+
export declare class NotModifiedError extends AimeeError {
|
|
67
67
|
readonly code = "NOT_MODIFIED";
|
|
68
68
|
readonly statusCode = 304;
|
|
69
69
|
}
|
|
@@ -71,7 +71,7 @@ export declare class NotModifiedError extends ZiftrError {
|
|
|
71
71
|
* Thrown when rate limit is exceeded (429).
|
|
72
72
|
* Includes retryAfter in seconds.
|
|
73
73
|
*/
|
|
74
|
-
export declare class RateLimitError extends
|
|
74
|
+
export declare class RateLimitError extends AimeeError {
|
|
75
75
|
readonly code = "RATE_LIMIT_EXCEEDED";
|
|
76
76
|
readonly statusCode = 429;
|
|
77
77
|
readonly retryAfter: number;
|
|
@@ -83,7 +83,7 @@ export declare class RateLimitError extends ZiftrError {
|
|
|
83
83
|
* (e.g. a secret key passed to a browser entry point). Client-side only;
|
|
84
84
|
* statusCode 0 because no request was made.
|
|
85
85
|
*/
|
|
86
|
-
export declare class ConfigurationError extends
|
|
86
|
+
export declare class ConfigurationError extends AimeeError {
|
|
87
87
|
readonly code = "CONFIGURATION_ERROR";
|
|
88
88
|
readonly statusCode = 0;
|
|
89
89
|
}
|
|
@@ -91,7 +91,7 @@ export declare class ConfigurationError extends ZiftrError {
|
|
|
91
91
|
* Generic API error for unhandled status codes.
|
|
92
92
|
* Use when no specific error type matches.
|
|
93
93
|
*/
|
|
94
|
-
export declare class ApiError extends
|
|
94
|
+
export declare class ApiError extends AimeeError {
|
|
95
95
|
readonly code: string;
|
|
96
96
|
readonly statusCode: number;
|
|
97
97
|
readonly details?: unknown;
|