@aimee.shop/sdk 0.0.1 → 0.0.2
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/config.d.ts +9 -9
- package/dist/core/config.js +37 -37
- 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.js +9 -9
- 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 +5 -5
- package/dist/index.js +4 -4
- 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/shipping/types.d.ts.map +1 -1
- package/dist/storefront/index.d.ts +9 -9
- package/dist/storefront/index.d.ts.map +1 -1
- package/dist/storefront/index.js +7 -7
- 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');
|
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
|
package/dist/core/config.js
CHANGED
|
@@ -8,26 +8,26 @@ function getNextPublicEnv(name) {
|
|
|
8
8
|
if (typeof process === 'undefined' || !process.env)
|
|
9
9
|
return undefined;
|
|
10
10
|
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.
|
|
11
|
+
case 'AIMEE_CORE_API_URL':
|
|
12
|
+
return process.env.NEXT_PUBLIC_AIMEE_CORE_API_URL;
|
|
13
|
+
case 'AIMEE_RBAC_API_URL':
|
|
14
|
+
return process.env.NEXT_PUBLIC_AIMEE_RBAC_API_URL;
|
|
15
|
+
case 'AIMEE_PAYMENTS_API_URL':
|
|
16
|
+
return process.env.NEXT_PUBLIC_AIMEE_PAYMENTS_API_URL;
|
|
17
|
+
case 'AIMEE_WORKFLOWS_API_URL':
|
|
18
|
+
return process.env.NEXT_PUBLIC_AIMEE_WORKFLOWS_API_URL;
|
|
19
|
+
case 'AIMEE_NOTIFICATIONS_API_URL':
|
|
20
|
+
return process.env.NEXT_PUBLIC_AIMEE_NOTIFICATIONS_API_URL;
|
|
21
|
+
case 'AIMEE_AI_API_URL':
|
|
22
|
+
return process.env.NEXT_PUBLIC_AIMEE_AI_API_URL;
|
|
23
|
+
case 'AIMEE_COGNITO_USER_POOL_ID':
|
|
24
|
+
return process.env.NEXT_PUBLIC_AIMEE_COGNITO_USER_POOL_ID;
|
|
25
|
+
case 'AIMEE_COGNITO_CLIENT_ID':
|
|
26
|
+
return process.env.NEXT_PUBLIC_AIMEE_COGNITO_CLIENT_ID;
|
|
27
|
+
case 'AIMEE_COGNITO_REGION':
|
|
28
|
+
return process.env.NEXT_PUBLIC_AIMEE_COGNITO_REGION;
|
|
29
|
+
case 'AIMEE_ENV':
|
|
30
|
+
return process.env.NEXT_PUBLIC_AIMEE_ENV;
|
|
31
31
|
default:
|
|
32
32
|
return undefined;
|
|
33
33
|
}
|
|
@@ -54,22 +54,22 @@ function gatewayEndpoints(baseUrl) {
|
|
|
54
54
|
// Each host is the bare gateway origin with NO /v1 -- clients append /v1/<service>.
|
|
55
55
|
const CANONICAL_HOSTS = {
|
|
56
56
|
local: 'http://localhost:3000',
|
|
57
|
-
dev: 'https://api-dev.
|
|
58
|
-
staging: 'https://api-staging.
|
|
59
|
-
production: 'https://api.
|
|
57
|
+
dev: 'https://api-dev.aimee.shop',
|
|
58
|
+
staging: 'https://api-staging.aimee.shop',
|
|
59
|
+
production: 'https://api.aimee.com',
|
|
60
60
|
};
|
|
61
|
-
// Per-service precedence:
|
|
61
|
+
// Per-service precedence: AIMEE_<SERVICE>_API_URL > AIMEE_CORE_API_URL > canonical host.
|
|
62
62
|
// Locally, non-core services fall back to localhost:3000 and expect a per-service override
|
|
63
|
-
// (e.g.
|
|
63
|
+
// (e.g. AIMEE_RBAC_API_URL=http://localhost:3001) for direct-to-service access.
|
|
64
64
|
function resolveEndpoints(env) {
|
|
65
|
-
const base = getEnv('
|
|
65
|
+
const base = getEnv('AIMEE_CORE_API_URL') ?? CANONICAL_HOSTS[env];
|
|
66
66
|
return {
|
|
67
67
|
...gatewayEndpoints(base),
|
|
68
|
-
rbacApi: getEnv('
|
|
69
|
-
paymentsApi: getEnv('
|
|
70
|
-
workflowsApi: getEnv('
|
|
71
|
-
notificationsApi: getEnv('
|
|
72
|
-
aiApi: getEnv('
|
|
68
|
+
rbacApi: getEnv('AIMEE_RBAC_API_URL') ?? base,
|
|
69
|
+
paymentsApi: getEnv('AIMEE_PAYMENTS_API_URL') ?? base,
|
|
70
|
+
workflowsApi: getEnv('AIMEE_WORKFLOWS_API_URL') ?? base,
|
|
71
|
+
notificationsApi: getEnv('AIMEE_NOTIFICATIONS_API_URL') ?? base,
|
|
72
|
+
aiApi: getEnv('AIMEE_AI_API_URL') ?? base,
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
// Each environment maps to a canonical gateway host; env vars override per service.
|
|
@@ -85,13 +85,13 @@ const PROD_COGNITO = {
|
|
|
85
85
|
region: 'us-east-2',
|
|
86
86
|
};
|
|
87
87
|
function resolveCognito() {
|
|
88
|
-
const userPoolId = getEnv('
|
|
89
|
-
const clientId = getEnv('
|
|
88
|
+
const userPoolId = getEnv('AIMEE_COGNITO_USER_POOL_ID');
|
|
89
|
+
const clientId = getEnv('AIMEE_COGNITO_CLIENT_ID');
|
|
90
90
|
if (userPoolId && clientId) {
|
|
91
91
|
return {
|
|
92
92
|
userPoolId,
|
|
93
93
|
clientId,
|
|
94
|
-
region: getEnv('
|
|
94
|
+
region: getEnv('AIMEE_COGNITO_REGION') ?? 'us-east-2',
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
return PROD_COGNITO;
|
|
@@ -105,12 +105,12 @@ export const DEFAULT_CONFIG = {
|
|
|
105
105
|
interactive: false,
|
|
106
106
|
};
|
|
107
107
|
const VALID_ENVIRONMENTS = ['local', 'dev', 'staging', 'production'];
|
|
108
|
-
function
|
|
108
|
+
function isAimeeEnvironment(env) {
|
|
109
109
|
return VALID_ENVIRONMENTS.some((validEnvironment) => validEnvironment === env);
|
|
110
110
|
}
|
|
111
111
|
export function detectEnvironment() {
|
|
112
|
-
const env = getEnv('
|
|
113
|
-
if (env &&
|
|
112
|
+
const env = getEnv('AIMEE_ENV');
|
|
113
|
+
if (env && isAimeeEnvironment(env))
|
|
114
114
|
return env;
|
|
115
115
|
if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'development')
|
|
116
116
|
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":"AAoEA;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,IAAY;IACpC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC;IAErE,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,oBAAoB;YACvB,OAAO,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC;QACpD,KAAK,oBAAoB;YACvB,OAAO,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC;QACpD,KAAK,wBAAwB;YAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC;QACxD,KAAK,yBAAyB;YAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC;QACzD,KAAK,6BAA6B;YAChC,OAAO,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC;QAC7D,KAAK,kBAAkB;YACrB,OAAO,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;QAClD,KAAK,4BAA4B;YAC/B,OAAO,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC;QAC5D,KAAK,yBAAyB;YAC5B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G;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;
|
|
@@ -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 class
|
|
5
|
+
export class AimeeError extends Error {
|
|
6
6
|
constructor(message) {
|
|
7
7
|
super(message);
|
|
8
8
|
this.name = this.constructor.name;
|
|
@@ -21,7 +21,7 @@ export class ZiftrError extends Error {
|
|
|
21
21
|
* Thrown when authentication fails (401).
|
|
22
22
|
* Examples: Invalid API key, expired token, missing credentials.
|
|
23
23
|
*/
|
|
24
|
-
export class AuthenticationError extends
|
|
24
|
+
export class AuthenticationError extends AimeeError {
|
|
25
25
|
code = 'AUTHENTICATION_ERROR';
|
|
26
26
|
statusCode = 401;
|
|
27
27
|
}
|
|
@@ -29,7 +29,7 @@ export class AuthenticationError extends ZiftrError {
|
|
|
29
29
|
* Thrown when authorization fails (403).
|
|
30
30
|
* Examples: Insufficient permissions, wrong tenant context.
|
|
31
31
|
*/
|
|
32
|
-
export class AuthorizationError extends
|
|
32
|
+
export class AuthorizationError extends AimeeError {
|
|
33
33
|
code = 'AUTHORIZATION_ERROR';
|
|
34
34
|
statusCode = 403;
|
|
35
35
|
}
|
|
@@ -37,7 +37,7 @@ export class AuthorizationError extends ZiftrError {
|
|
|
37
37
|
* Thrown when request validation fails (400).
|
|
38
38
|
* Includes field-level errors for form handling.
|
|
39
39
|
*/
|
|
40
|
-
export class ValidationError extends
|
|
40
|
+
export class ValidationError extends AimeeError {
|
|
41
41
|
code = 'VALIDATION_ERROR';
|
|
42
42
|
statusCode = 400;
|
|
43
43
|
errors;
|
|
@@ -52,7 +52,7 @@ export class ValidationError extends ZiftrError {
|
|
|
52
52
|
/**
|
|
53
53
|
* Thrown when a resource is not found (404).
|
|
54
54
|
*/
|
|
55
|
-
export class NotFoundError extends
|
|
55
|
+
export class NotFoundError extends AimeeError {
|
|
56
56
|
code = 'NOT_FOUND';
|
|
57
57
|
statusCode = 404;
|
|
58
58
|
}
|
|
@@ -60,7 +60,7 @@ export class NotFoundError extends ZiftrError {
|
|
|
60
60
|
* Thrown when a request conflicts with current resource state (409).
|
|
61
61
|
* Examples: stale navigation revision (If-Match / expectedRevision mismatch).
|
|
62
62
|
*/
|
|
63
|
-
export class ConflictError extends
|
|
63
|
+
export class ConflictError extends AimeeError {
|
|
64
64
|
code = 'CONFLICT';
|
|
65
65
|
statusCode = 409;
|
|
66
66
|
}
|
|
@@ -69,7 +69,7 @@ export class ConflictError extends ZiftrError {
|
|
|
69
69
|
* Examples: public getNavigation with a matching If-None-Match ETag.
|
|
70
70
|
* This is a cache hit, not a failure -- catch it instead of treating as ApiError.
|
|
71
71
|
*/
|
|
72
|
-
export class NotModifiedError extends
|
|
72
|
+
export class NotModifiedError extends AimeeError {
|
|
73
73
|
code = 'NOT_MODIFIED';
|
|
74
74
|
statusCode = 304;
|
|
75
75
|
}
|
|
@@ -77,7 +77,7 @@ export class NotModifiedError extends ZiftrError {
|
|
|
77
77
|
* Thrown when rate limit is exceeded (429).
|
|
78
78
|
* Includes retryAfter in seconds.
|
|
79
79
|
*/
|
|
80
|
-
export class RateLimitError extends
|
|
80
|
+
export class RateLimitError extends AimeeError {
|
|
81
81
|
code = 'RATE_LIMIT_EXCEEDED';
|
|
82
82
|
statusCode = 429;
|
|
83
83
|
retryAfter;
|
|
@@ -94,7 +94,7 @@ export class RateLimitError extends ZiftrError {
|
|
|
94
94
|
* (e.g. a secret key passed to a browser entry point). Client-side only;
|
|
95
95
|
* statusCode 0 because no request was made.
|
|
96
96
|
*/
|
|
97
|
-
export class ConfigurationError extends
|
|
97
|
+
export class ConfigurationError extends AimeeError {
|
|
98
98
|
code = 'CONFIGURATION_ERROR';
|
|
99
99
|
statusCode = 0;
|
|
100
100
|
}
|
|
@@ -102,7 +102,7 @@ export class ConfigurationError extends ZiftrError {
|
|
|
102
102
|
* Generic API error for unhandled status codes.
|
|
103
103
|
* Use when no specific error type matches.
|
|
104
104
|
*/
|
|
105
|
-
export class ApiError extends
|
|
105
|
+
export class ApiError extends AimeeError {
|
|
106
106
|
code;
|
|
107
107
|
statusCode;
|
|
108
108
|
details;
|
|
@@ -18,7 +18,7 @@ export interface BaseEventEnvelope<TPayload = Record<string, unknown>> {
|
|
|
18
18
|
eventVersion: string;
|
|
19
19
|
/** ISO 8601 timestamp of when the event was emitted */
|
|
20
20
|
timestamp: string;
|
|
21
|
-
/** Service that emitted the event (e.g., '
|
|
21
|
+
/** Service that emitted the event (e.g., 'aimee.core-api') */
|
|
22
22
|
source: string;
|
|
23
23
|
/** Tenant identifier -- always present for multi-tenant isolation */
|
|
24
24
|
tenantId: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Canonical event name constants for the
|
|
2
|
+
* Canonical event name constants for the Aimee platform.
|
|
3
3
|
*
|
|
4
4
|
* All event names use lowercase dot notation per the event-driven architecture standard.
|
|
5
5
|
* One event per write operation across all services, derived from SDK client methods.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Canonical event name constants for the
|
|
2
|
+
* Canonical event name constants for the Aimee platform.
|
|
3
3
|
*
|
|
4
4
|
* All event names use lowercase dot notation per the event-driven architecture standard.
|
|
5
5
|
* One event per write operation across all services, derived from SDK client methods.
|