@symbo.ls/sdk 2.34.35 → 3.1.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/README.md +2 -143
- package/dist/cjs/config/environment.js +30 -98
- package/dist/cjs/index.js +24 -144
- package/dist/cjs/services/AIService.js +155 -0
- package/dist/cjs/services/AuthService.js +305 -738
- package/dist/cjs/services/BaseService.js +6 -158
- package/dist/cjs/services/BasedService.js +1185 -0
- package/dist/cjs/services/CoreService.js +1751 -0
- package/dist/cjs/services/SocketIOService.js +307 -0
- package/dist/cjs/services/SocketService.js +161 -0
- package/dist/cjs/services/SymstoryService.js +571 -0
- package/dist/cjs/services/index.js +16 -64
- package/dist/cjs/utils/TokenManager.js +30 -78
- package/dist/cjs/utils/basedQuerys.js +181 -0
- package/dist/cjs/utils/services.js +103 -301
- package/dist/cjs/utils/symstoryClient.js +259 -0
- package/dist/cjs/utils/validation.js +3 -0
- package/dist/esm/config/environment.js +30 -98
- package/dist/esm/index.js +8797 -49416
- package/dist/esm/services/AIService.js +185 -0
- package/dist/esm/services/AuthService.js +386 -1493
- package/dist/esm/services/BaseService.js +6 -757
- package/dist/esm/services/BasedService.js +5278 -0
- package/dist/esm/services/CoreService.js +2264 -0
- package/dist/esm/services/SocketIOService.js +470 -0
- package/dist/esm/services/SocketService.js +191 -0
- package/dist/esm/services/SymstoryService.js +7041 -0
- package/dist/esm/services/index.js +8690 -49015
- package/dist/esm/utils/TokenManager.js +30 -78
- package/dist/esm/utils/basedQuerys.js +163 -0
- package/dist/esm/utils/services.js +103 -301
- package/dist/esm/utils/symstoryClient.js +370 -0
- package/dist/esm/utils/validation.js +7 -4
- package/dist/node/config/environment.js +30 -98
- package/dist/node/index.js +32 -175
- package/dist/node/services/AIService.js +136 -0
- package/dist/node/services/AuthService.js +310 -742
- package/dist/node/services/BaseService.js +6 -148
- package/dist/node/services/BasedService.js +1156 -0
- package/dist/node/services/CoreService.js +1722 -0
- package/dist/node/services/SocketIOService.js +278 -0
- package/dist/node/services/SocketService.js +142 -0
- package/dist/node/services/SymstoryService.js +542 -0
- package/dist/node/services/index.js +16 -64
- package/dist/node/utils/TokenManager.js +30 -78
- package/dist/node/utils/basedQuerys.js +162 -0
- package/dist/node/utils/services.js +103 -301
- package/dist/node/utils/symstoryClient.js +230 -0
- package/dist/node/utils/validation.js +3 -0
- package/package.json +16 -35
- package/src/config/environment.js +28 -99
- package/src/index.js +36 -181
- package/src/services/AIService.js +150 -0
- package/src/services/AuthService.js +328 -874
- package/src/services/BaseService.js +6 -166
- package/src/services/BasedService.js +1301 -0
- package/src/services/CoreService.js +1943 -0
- package/src/services/SocketIOService.js +334 -0
- package/src/services/SocketService.js +168 -0
- package/src/services/SymstoryService.js +649 -0
- package/src/services/index.js +13 -80
- package/src/utils/TokenManager.js +33 -88
- package/src/utils/basedQuerys.js +164 -0
- package/src/utils/services.js +107 -326
- package/src/utils/symstoryClient.js +252 -0
- package/src/utils/validation.js +3 -0
- package/dist/cjs/services/AdminService.js +0 -351
- package/dist/cjs/services/BranchService.js +0 -484
- package/dist/cjs/services/CollabService.js +0 -743
- package/dist/cjs/services/DnsService.js +0 -340
- package/dist/cjs/services/FeatureFlagService.js +0 -175
- package/dist/cjs/services/FileService.js +0 -201
- package/dist/cjs/services/IntegrationService.js +0 -538
- package/dist/cjs/services/MetricsService.js +0 -62
- package/dist/cjs/services/PaymentService.js +0 -271
- package/dist/cjs/services/PlanService.js +0 -426
- package/dist/cjs/services/ProjectService.js +0 -1207
- package/dist/cjs/services/PullRequestService.js +0 -503
- package/dist/cjs/services/ScreenshotService.js +0 -304
- package/dist/cjs/services/SubscriptionService.js +0 -396
- package/dist/cjs/services/TrackingService.js +0 -661
- package/dist/cjs/services/WaitlistService.js +0 -148
- package/dist/cjs/state/RootStateManager.js +0 -65
- package/dist/cjs/state/rootEventBus.js +0 -74
- package/dist/cjs/utils/CollabClient.js +0 -223
- package/dist/cjs/utils/changePreprocessor.js +0 -199
- package/dist/cjs/utils/jsonDiff.js +0 -145
- package/dist/cjs/utils/ordering.js +0 -309
- package/dist/esm/services/AdminService.js +0 -1132
- package/dist/esm/services/BranchService.js +0 -1265
- package/dist/esm/services/CollabService.js +0 -26838
- package/dist/esm/services/DnsService.js +0 -1121
- package/dist/esm/services/FeatureFlagService.js +0 -956
- package/dist/esm/services/FileService.js +0 -982
- package/dist/esm/services/IntegrationService.js +0 -1319
- package/dist/esm/services/MetricsService.js +0 -843
- package/dist/esm/services/PaymentService.js +0 -1052
- package/dist/esm/services/PlanService.js +0 -1207
- package/dist/esm/services/ProjectService.js +0 -2526
- package/dist/esm/services/PullRequestService.js +0 -1284
- package/dist/esm/services/ScreenshotService.js +0 -1085
- package/dist/esm/services/SubscriptionService.js +0 -1177
- package/dist/esm/services/TrackingService.js +0 -18343
- package/dist/esm/services/WaitlistService.js +0 -929
- package/dist/esm/state/RootStateManager.js +0 -90
- package/dist/esm/state/rootEventBus.js +0 -56
- package/dist/esm/utils/CollabClient.js +0 -18901
- package/dist/esm/utils/changePreprocessor.js +0 -542
- package/dist/esm/utils/jsonDiff.js +0 -7011
- package/dist/esm/utils/ordering.js +0 -291
- package/dist/node/services/AdminService.js +0 -332
- package/dist/node/services/BranchService.js +0 -465
- package/dist/node/services/CollabService.js +0 -724
- package/dist/node/services/DnsService.js +0 -321
- package/dist/node/services/FeatureFlagService.js +0 -156
- package/dist/node/services/FileService.js +0 -182
- package/dist/node/services/IntegrationService.js +0 -519
- package/dist/node/services/MetricsService.js +0 -43
- package/dist/node/services/PaymentService.js +0 -252
- package/dist/node/services/PlanService.js +0 -407
- package/dist/node/services/ProjectService.js +0 -1188
- package/dist/node/services/PullRequestService.js +0 -484
- package/dist/node/services/ScreenshotService.js +0 -285
- package/dist/node/services/SubscriptionService.js +0 -377
- package/dist/node/services/TrackingService.js +0 -632
- package/dist/node/services/WaitlistService.js +0 -129
- package/dist/node/state/RootStateManager.js +0 -36
- package/dist/node/state/rootEventBus.js +0 -55
- package/dist/node/utils/CollabClient.js +0 -194
- package/dist/node/utils/changePreprocessor.js +0 -180
- package/dist/node/utils/jsonDiff.js +0 -116
- package/dist/node/utils/ordering.js +0 -290
- package/src/services/AdminService.js +0 -374
- package/src/services/BranchService.js +0 -536
- package/src/services/CollabService.js +0 -900
- package/src/services/DnsService.js +0 -366
- package/src/services/FeatureFlagService.js +0 -174
- package/src/services/FileService.js +0 -213
- package/src/services/IntegrationService.js +0 -548
- package/src/services/MetricsService.js +0 -40
- package/src/services/PaymentService.js +0 -287
- package/src/services/PlanService.js +0 -468
- package/src/services/ProjectService.js +0 -1366
- package/src/services/PullRequestService.js +0 -537
- package/src/services/ScreenshotService.js +0 -258
- package/src/services/SubscriptionService.js +0 -425
- package/src/services/TrackingService.js +0 -853
- package/src/services/WaitlistService.js +0 -130
- package/src/services/tests/BranchService/createBranch.test.js +0 -153
- package/src/services/tests/BranchService/deleteBranch.test.js +0 -173
- package/src/services/tests/BranchService/getBranchChanges.test.js +0 -146
- package/src/services/tests/BranchService/listBranches.test.js +0 -87
- package/src/services/tests/BranchService/mergeBranch.test.js +0 -210
- package/src/services/tests/BranchService/publishVersion.test.js +0 -183
- package/src/services/tests/BranchService/renameBranch.test.js +0 -240
- package/src/services/tests/BranchService/resetBranch.test.js +0 -152
- package/src/services/tests/FeatureFlagService/adminFeatureFlags.test.js +0 -67
- package/src/services/tests/FeatureFlagService/getFeatureFlags.test.js +0 -75
- package/src/services/tests/FileService/createFileFormData.test.js +0 -74
- package/src/services/tests/FileService/getFileUrl.test.js +0 -69
- package/src/services/tests/FileService/updateProjectIcon.test.js +0 -109
- package/src/services/tests/FileService/uploadDocument.test.js +0 -36
- package/src/services/tests/FileService/uploadFile.test.js +0 -78
- package/src/services/tests/FileService/uploadFileWithValidation.test.js +0 -114
- package/src/services/tests/FileService/uploadImage.test.js +0 -36
- package/src/services/tests/FileService/uploadMultipleFiles.test.js +0 -111
- package/src/services/tests/FileService/validateFile.test.js +0 -63
- package/src/services/tests/PlanService/createPlan.test.js +0 -104
- package/src/services/tests/PlanService/createPlanWithValidation.test.js +0 -523
- package/src/services/tests/PlanService/deletePlan.test.js +0 -92
- package/src/services/tests/PlanService/getActivePlans.test.js +0 -123
- package/src/services/tests/PlanService/getAdminPlans.test.js +0 -84
- package/src/services/tests/PlanService/getPlan.test.js +0 -50
- package/src/services/tests/PlanService/getPlanByKey.test.js +0 -109
- package/src/services/tests/PlanService/getPlanWithValidation.test.js +0 -85
- package/src/services/tests/PlanService/getPlans.test.js +0 -53
- package/src/services/tests/PlanService/getPlansByPriceRange.test.js +0 -109
- package/src/services/tests/PlanService/getPlansWithValidation.test.js +0 -48
- package/src/services/tests/PlanService/initializePlans.test.js +0 -75
- package/src/services/tests/PlanService/updatePlan.test.js +0 -111
- package/src/services/tests/PlanService/updatePlanWithValidation.test.js +0 -556
- package/src/state/RootStateManager.js +0 -76
- package/src/state/rootEventBus.js +0 -67
- package/src/utils/CollabClient.js +0 -248
- package/src/utils/changePreprocessor.js +0 -239
- package/src/utils/jsonDiff.js +0 -144
- package/src/utils/ordering.js +0 -271
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ import { SDK } from '@symbo.ls/sdk'
|
|
|
12
12
|
|
|
13
13
|
const sdk = new SDK({
|
|
14
14
|
useNewServices: true, // Use new service implementations
|
|
15
|
-
|
|
15
|
+
baseUrl: 'https://api.symbols.app',
|
|
16
16
|
socketUrl: 'https://api.symbols.app',
|
|
17
17
|
timeout: 30000,
|
|
18
18
|
retryAttempts: 3,
|
|
@@ -377,147 +377,6 @@ const ai = sdk.getService('ai')
|
|
|
377
377
|
const response = await ai.prompt(query, options)
|
|
378
378
|
```
|
|
379
379
|
|
|
380
|
-
### Tracking Service (Grafana Faro)
|
|
381
|
-
```javascript
|
|
382
|
-
// 1) Initialize SDK with tracking config (early in app startup)
|
|
383
|
-
const sdk = new SDK({
|
|
384
|
-
useNewServices: true,
|
|
385
|
-
apiUrl: 'https://api.symbols.app',
|
|
386
|
-
// Tracking configuration mirrors TrackingService options
|
|
387
|
-
tracking: {
|
|
388
|
-
url: 'https://<your-faro-receiver-url>', // FO ingest/collector URL
|
|
389
|
-
appName: 'Symbols Platform',
|
|
390
|
-
environment: 'development', // 'production' | 'staging' | 'testing' | 'development'
|
|
391
|
-
appVersion: '1.0.0',
|
|
392
|
-
sessionTracking: true,
|
|
393
|
-
enableTracing: true, // adds browser tracing when available
|
|
394
|
-
globalAttributes: { region: 'us-east-1' }
|
|
395
|
-
}
|
|
396
|
-
})
|
|
397
|
-
await sdk.initialize()
|
|
398
|
-
|
|
399
|
-
// 2) Get the tracking service
|
|
400
|
-
const tracking = sdk.getService('tracking')
|
|
401
|
-
|
|
402
|
-
// 3) Send signals
|
|
403
|
-
tracking.trackEvent('purchase', { amount: 42, currency: 'USD' })
|
|
404
|
-
tracking.trackMeasurement('cart_value', { value: 42 })
|
|
405
|
-
tracking.logError('checkout failed', { step: 'payment' })
|
|
406
|
-
tracking.trackView('Checkout', { stage: 'payment' })
|
|
407
|
-
tracking.setUser({ id: 'u_123', email: 'user@example.com' })
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
#### Configuration
|
|
411
|
-
Provide these under `tracking` when creating the `SDK` (or later via `tracking.configureTracking()`):
|
|
412
|
-
|
|
413
|
-
- `url` string: Frontend Observability/Faro ingestion URL. If omitted and no custom transports are provided, tracking is disabled.
|
|
414
|
-
- `appName` string: Logical application name used in Grafana dashboards.
|
|
415
|
-
- `appVersion` string: App version shown in Grafana.
|
|
416
|
-
- `environment` string: One of your environments; default resolves from runtime (`production`, `staging`, `testing`, `development`).
|
|
417
|
-
- `sessionTracking` boolean: Enable Faro session tracking. Default: `true`.
|
|
418
|
-
- `enableTracing` boolean: Enable web tracing and send to Tempo (if collector configured). Default: `true`.
|
|
419
|
-
- `globalAttributes` object: Key/values merged into every signal.
|
|
420
|
-
- `user` object: Initial user attributes.
|
|
421
|
-
- `maxQueueSize` number: Max queued calls before client setup. Default: `100`.
|
|
422
|
-
- `isolate` boolean: Create an isolated Faro instance.
|
|
423
|
-
- `transports` array | `transport` any: Custom transports (advanced).
|
|
424
|
-
- `instrumentations` array | `instrumentationsFactory(runtime) => Promise<array>` | `webInstrumentationOptions` object: Control Faro web instrumentations.
|
|
425
|
-
|
|
426
|
-
Note:
|
|
427
|
-
- Tracking is automatically disabled in non‑browser environments.
|
|
428
|
-
- Calls are queued until the Faro client is ready. For specific calls, pass `{ queue: false }` to skip queuing.
|
|
429
|
-
|
|
430
|
-
#### Method reference
|
|
431
|
-
The following methods are available via `sdk.getService('tracking')` and map to `utils/services.js`:
|
|
432
|
-
|
|
433
|
-
- `configureTracking(trackingOptions)` / `configure(trackingOptions)`: Merge/override runtime tracking options (supports all config keys above).
|
|
434
|
-
- `trackEvent(name, attributes?, options?)`
|
|
435
|
-
- `name` string (required)
|
|
436
|
-
- `attributes` object merged with global attributes
|
|
437
|
-
- `options` object:
|
|
438
|
-
- `domain` string | null
|
|
439
|
-
- `queue` boolean (whether to queue if client not ready)
|
|
440
|
-
- Additional transport options are forwarded to Faro
|
|
441
|
-
- Example:
|
|
442
|
-
```javascript
|
|
443
|
-
tracking.trackEvent('signup_attempt', { method: 'email' }, { domain: 'auth' })
|
|
444
|
-
```
|
|
445
|
-
- `trackError(error, options?)` / `captureException(error, options?)`
|
|
446
|
-
- `error` Error | string
|
|
447
|
-
- `options` can be:
|
|
448
|
-
- object with Faro error options (`context`, `type`, `stackFrames`, `skipDedupe`, `timestampOverwriteMs`, etc.)
|
|
449
|
-
- or a plain context object (shorthand)
|
|
450
|
-
- `queue` boolean supported
|
|
451
|
-
- Example:
|
|
452
|
-
```javascript
|
|
453
|
-
tracking.trackError(new Error('Login failed'), { context: { screen: 'Login' } })
|
|
454
|
-
```
|
|
455
|
-
- `logMessage(message, level='info', context?)`
|
|
456
|
-
- Convenience wrappers: `logDebug`, `logInfo`, `logWarning`/`logWarn`, `logErrorMessage`/`logError`
|
|
457
|
-
- `message` string | string[]
|
|
458
|
-
- `context` object merged with global attributes
|
|
459
|
-
- Example:
|
|
460
|
-
```javascript
|
|
461
|
-
tracking.logWarning('Slow response', { route: '/checkout', ttfbMs: 900 })
|
|
462
|
-
```
|
|
463
|
-
- `addBreadcrumb(message, attributes?)`
|
|
464
|
-
- Adds a low‑cost breadcrumb via `trackEvent('breadcrumb', ...)`
|
|
465
|
-
- Example:
|
|
466
|
-
```javascript
|
|
467
|
-
tracking.addBreadcrumb('Open modal', { id: 'planLimits' })
|
|
468
|
-
```
|
|
469
|
-
- `trackMeasurement(type, values, options?)`
|
|
470
|
-
- `type` string (required)
|
|
471
|
-
- `values` object | number. If number, it becomes `{ value: <number> }`.
|
|
472
|
-
- `options`:
|
|
473
|
-
- `attributes` object (merged into payload.attributes)
|
|
474
|
-
- `context` object (transport context)
|
|
475
|
-
- `queue` boolean
|
|
476
|
-
- Any additional transport options
|
|
477
|
-
- Example:
|
|
478
|
-
```javascript
|
|
479
|
-
tracking.trackMeasurement('cart_value', 42, { context: { currency: 'USD' } })
|
|
480
|
-
```
|
|
481
|
-
- `trackView(name, attributes?)`
|
|
482
|
-
- Sets the current view/page in Faro
|
|
483
|
-
- Example:
|
|
484
|
-
```javascript
|
|
485
|
-
tracking.trackView('Dashboard', { section: 'Analytics' })
|
|
486
|
-
```
|
|
487
|
-
- `setUser(user, options?)` / `clearUser()`
|
|
488
|
-
- `user` object with arbitrary attributes; supports `{ queue: boolean }`
|
|
489
|
-
- Example:
|
|
490
|
-
```javascript
|
|
491
|
-
tracking.setUser({ id: 'u_123', role: 'admin' })
|
|
492
|
-
```
|
|
493
|
-
- `setSession(session, options?)` / `clearSession()`
|
|
494
|
-
- Attach custom session data; supports `{ queue: boolean, ...sessionOptions }`
|
|
495
|
-
- `setGlobalAttributes(attributes)` / `setGlobalAttribute(key, value)` / `removeGlobalAttribute(key)`
|
|
496
|
-
- Manage the global attributes merged into every signal
|
|
497
|
-
- `flushQueue()`
|
|
498
|
-
- Immediately runs all queued calls (no‑op if client not ready)
|
|
499
|
-
- `getClient()`
|
|
500
|
-
- Returns the underlying Faro client (or `null` if not ready)
|
|
501
|
-
- `isEnabled()` / `isInitialized()`
|
|
502
|
-
- Status helpers
|
|
503
|
-
|
|
504
|
-
#### Example: auth error tracking from services
|
|
505
|
-
The SDK’s services automatically send errors to tracking:
|
|
506
|
-
```javascript
|
|
507
|
-
try {
|
|
508
|
-
await auth.login(email, password)
|
|
509
|
-
} catch (error) {
|
|
510
|
-
// BaseService forwards details to tracking.trackError(...)
|
|
511
|
-
}
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
#### Visualizing in Grafana
|
|
515
|
-
- Use the Frontend Observability (Faro) data source and pick:
|
|
516
|
-
- Service = your `appName`
|
|
517
|
-
- Environment = your `environment`
|
|
518
|
-
- Panels for page loads and Web Vitals require web instrumentations and real page traffic.
|
|
519
|
-
- If self‑hosting with a Faro collector → Loki/Tempo, ensure the FO app is installed and the dashboard uses the FO data source; otherwise create custom panels with LogQL over Loki.
|
|
520
|
-
|
|
521
380
|
## Error Handling
|
|
522
381
|
```javascript
|
|
523
382
|
try {
|
|
@@ -537,7 +396,7 @@ sdk.destroy()
|
|
|
537
396
|
```javascript
|
|
538
397
|
const options = {
|
|
539
398
|
useNewServices: true,
|
|
540
|
-
|
|
399
|
+
baseUrl: 'https://api.symbols.app',
|
|
541
400
|
socketUrl: 'https://api.symbols.app',
|
|
542
401
|
timeout: 30000,
|
|
543
402
|
retryAttempts: 3,
|
|
@@ -30,16 +30,18 @@ const CONFIG = {
|
|
|
30
30
|
// Feature toggles that apply across all environments by default
|
|
31
31
|
features: {
|
|
32
32
|
newUserOnboarding: true,
|
|
33
|
-
betaFeatures: false
|
|
34
|
-
// Tracking is enabled by default unless overridden per environment
|
|
35
|
-
trackingEnabled: true
|
|
33
|
+
betaFeatures: false
|
|
36
34
|
}
|
|
37
35
|
},
|
|
38
36
|
// Environment-specific configurations
|
|
39
37
|
local: {
|
|
40
38
|
// local
|
|
39
|
+
baseUrl: "http://localhost:8080",
|
|
40
|
+
// For symstory api
|
|
41
41
|
socketUrl: "http://localhost:8080",
|
|
42
42
|
// For socket api
|
|
43
|
+
routerUrl: "http://localhost:8080",
|
|
44
|
+
// For router api
|
|
43
45
|
apiUrl: "http://localhost:8080",
|
|
44
46
|
// For server api
|
|
45
47
|
basedEnv: "development",
|
|
@@ -48,115 +50,53 @@ const CONFIG = {
|
|
|
48
50
|
// For based api
|
|
49
51
|
basedOrg: "symbols",
|
|
50
52
|
// For based api
|
|
51
|
-
githubClientId: "
|
|
53
|
+
githubClientId: "Ov23liHxyWFBxS8f1gnF",
|
|
52
54
|
// For github api
|
|
53
|
-
grafanaUrl: "",
|
|
54
|
-
// For grafana tracing
|
|
55
|
-
grafanaAppName: "Symbols Localhost",
|
|
56
55
|
// Environment-specific feature toggles (override common)
|
|
57
56
|
features: {
|
|
58
|
-
|
|
59
|
-
trackingEnabled: false,
|
|
57
|
+
betaFeatures: true
|
|
60
58
|
// Enable beta features in local dev
|
|
61
|
-
|
|
62
|
-
// Preserve common defaults explicitly for local
|
|
63
|
-
newUserOnboarding: true
|
|
64
|
-
},
|
|
65
|
-
typesenseCollectionName: "docs",
|
|
66
|
-
typesenseApiKey: "vZya3L2zpq8L6iI5WWMUZJZABvT63VDb",
|
|
67
|
-
typesenseHost: "localhost",
|
|
68
|
-
typesensePort: "8108",
|
|
69
|
-
typesenseProtocol: "http"
|
|
59
|
+
}
|
|
70
60
|
},
|
|
71
61
|
development: {
|
|
62
|
+
baseUrl: "https://dev.api.symbols.app",
|
|
72
63
|
socketUrl: "https://dev.api.symbols.app",
|
|
64
|
+
routerUrl: "https://dev.api.symbols.app",
|
|
73
65
|
apiUrl: "https://dev.api.symbols.app",
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
typesenseCollectionName: "docs",
|
|
79
|
-
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
80
|
-
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
81
|
-
typesensePort: "443",
|
|
82
|
-
typesenseProtocol: "https"
|
|
66
|
+
basedEnv: "development",
|
|
67
|
+
basedProject: "platform-v2-sm",
|
|
68
|
+
basedOrg: "symbols",
|
|
69
|
+
githubClientId: "Ov23liHxyWFBxS8f1gnF"
|
|
83
70
|
},
|
|
84
71
|
testing: {
|
|
72
|
+
baseUrl: "https://test.api.symbols.app",
|
|
85
73
|
socketUrl: "https://test.api.symbols.app",
|
|
74
|
+
routerUrl: "https://test.api.symbols.app",
|
|
86
75
|
apiUrl: "https://test.api.symbols.app",
|
|
87
76
|
basedEnv: "testing",
|
|
88
77
|
basedProject: "platform-v2-sm",
|
|
89
78
|
basedOrg: "symbols",
|
|
90
|
-
githubClientId: "Ov23liHxyWFBxS8f1gnF"
|
|
91
|
-
grafanaUrl: "",
|
|
92
|
-
// For grafana tracing
|
|
93
|
-
grafanaAppName: "Symbols Test",
|
|
94
|
-
typesenseCollectionName: "docs",
|
|
95
|
-
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
96
|
-
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
97
|
-
typesensePort: "443",
|
|
98
|
-
typesenseProtocol: "https"
|
|
99
|
-
},
|
|
100
|
-
upcoming: {
|
|
101
|
-
socketUrl: "https://upcoming.api.symbols.app",
|
|
102
|
-
apiUrl: "https://upcoming.api.symbols.app",
|
|
103
|
-
githubClientId: "Ov23liWF7NvdZ056RV5J",
|
|
104
|
-
grafanaUrl: "",
|
|
105
|
-
// For grafana tracing
|
|
106
|
-
grafanaAppName: "Symbols Upcoming",
|
|
107
|
-
typesenseCollectionName: "docs",
|
|
108
|
-
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
109
|
-
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
110
|
-
typesensePort: "443",
|
|
111
|
-
typesenseProtocol: "https"
|
|
79
|
+
githubClientId: "Ov23liHxyWFBxS8f1gnF"
|
|
112
80
|
},
|
|
113
81
|
staging: {
|
|
82
|
+
baseUrl: "https://staging.api.symbols.app",
|
|
114
83
|
socketUrl: "https://staging.api.symbols.app",
|
|
84
|
+
routerUrl: "https://staging.api.symbols.app",
|
|
115
85
|
apiUrl: "https://staging.api.symbols.app",
|
|
116
86
|
basedEnv: "staging",
|
|
117
87
|
basedProject: "platform-v2-sm",
|
|
118
88
|
basedOrg: "symbols",
|
|
119
|
-
githubClientId: "Ov23ligwZDQVD0VfuWNa"
|
|
120
|
-
grafanaUrl: "",
|
|
121
|
-
// For grafana tracing
|
|
122
|
-
grafanaAppName: "Symbols Staging",
|
|
123
|
-
typesenseCollectionName: "docs",
|
|
124
|
-
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
125
|
-
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
126
|
-
typesensePort: "443",
|
|
127
|
-
typesenseProtocol: "https"
|
|
128
|
-
},
|
|
129
|
-
preview: {
|
|
130
|
-
socketUrl: "https://api.symbols.app",
|
|
131
|
-
apiUrl: "https://api.symbols.app",
|
|
132
|
-
basedEnv: "production",
|
|
133
|
-
basedProject: "platform-v2-sm",
|
|
134
|
-
basedOrg: "symbols",
|
|
135
|
-
githubClientId: "Ov23liFAlOEIXtX3dBtR",
|
|
136
|
-
grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/5c1089f3c3eea4ec5658e05c3f53baae",
|
|
137
|
-
// For grafana tracing
|
|
138
|
-
grafanaAppName: "Symbols Preview",
|
|
139
|
-
typesenseCollectionName: "docs",
|
|
140
|
-
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
141
|
-
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
142
|
-
typesensePort: "443",
|
|
143
|
-
typesenseProtocol: "https"
|
|
89
|
+
githubClientId: "Ov23ligwZDQVD0VfuWNa"
|
|
144
90
|
},
|
|
145
91
|
production: {
|
|
92
|
+
baseUrl: "https://api.symbols.app",
|
|
146
93
|
socketUrl: "https://api.symbols.app",
|
|
94
|
+
routerUrl: "https://api.symbols.app",
|
|
147
95
|
apiUrl: "https://api.symbols.app",
|
|
148
96
|
basedEnv: "production",
|
|
149
97
|
basedProject: "platform-v2-sm",
|
|
150
98
|
basedOrg: "symbols",
|
|
151
|
-
githubClientId: "Ov23liFAlOEIXtX3dBtR"
|
|
152
|
-
grafanaUrl: "https://faro-collector-prod-us-east-0.grafana.net/collect/5c1089f3c3eea4ec5658e05c3f53baae",
|
|
153
|
-
// For grafana tracing
|
|
154
|
-
grafanaAppName: "Symbols",
|
|
155
|
-
typesenseCollectionName: "docs",
|
|
156
|
-
typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
|
|
157
|
-
typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
|
|
158
|
-
typesensePort: "443",
|
|
159
|
-
typesenseProtocol: "https"
|
|
99
|
+
githubClientId: "Ov23liFAlOEIXtX3dBtR"
|
|
160
100
|
}
|
|
161
101
|
};
|
|
162
102
|
const getEnvironment = () => {
|
|
@@ -173,33 +113,27 @@ const getConfig = () => {
|
|
|
173
113
|
const envConfig = { ...CONFIG.common, ...CONFIG[env] };
|
|
174
114
|
const finalConfig = {
|
|
175
115
|
...envConfig,
|
|
176
|
-
|
|
177
|
-
features: {
|
|
178
|
-
...CONFIG.common.features || {},
|
|
179
|
-
...CONFIG[env] && CONFIG[env].features || {}
|
|
180
|
-
},
|
|
116
|
+
baseUrl: process.env.SYMBOLS_APP_BASE_URL || envConfig.baseUrl,
|
|
181
117
|
socketUrl: process.env.SYMBOLS_APP_SOCKET_URL || envConfig.socketUrl,
|
|
118
|
+
routerUrl: process.env.SYMBOLS_APP_ROUTER_URL || envConfig.routerUrl,
|
|
182
119
|
apiUrl: process.env.SYMBOLS_APP_API_URL || envConfig.apiUrl,
|
|
183
120
|
basedEnv: process.env.SYMBOLS_APP_BASED_ENV || envConfig.basedEnv,
|
|
184
121
|
basedProject: process.env.SYMBOLS_APP_BASED_PROJECT || envConfig.basedProject,
|
|
185
122
|
basedOrg: process.env.SYMBOLS_APP_BASED_ORG || envConfig.basedOrg,
|
|
186
123
|
githubClientId: process.env.SYMBOLS_APP_GITHUB_CLIENT_ID || envConfig.githubClientId,
|
|
187
|
-
grafanaUrl: process.env.SYMBOLS_APP_GRAFANA_URL || envConfig.grafanaUrl,
|
|
188
|
-
typesenseCollectionName: process.env.TYPESENSE_COLLECTION_NAME || envConfig.typesenseCollectionName,
|
|
189
|
-
typesenseApiKey: process.env.TYPESENSE_API_KEY || envConfig.typesenseApiKey,
|
|
190
|
-
typesenseHost: process.env.TYPESENSE_HOST || envConfig.typesenseHost,
|
|
191
|
-
typesensePort: process.env.TYPESENSE_PORT || envConfig.typesensePort,
|
|
192
|
-
typesenseProtocol: process.env.TYPESENSE_PROTOCOL || envConfig.typesenseProtocol,
|
|
193
124
|
isDevelopment: (0, import_utils.isDevelopment)(env),
|
|
194
125
|
isTesting: env === "testing",
|
|
195
126
|
isStaging: env === "staging",
|
|
196
|
-
isPreview: env === "preview",
|
|
197
127
|
isProduction: env === "production"
|
|
198
128
|
// Store all environment variables for potential future use
|
|
199
129
|
};
|
|
200
130
|
const requiredFields = [
|
|
131
|
+
"baseUrl",
|
|
201
132
|
"socketUrl",
|
|
202
133
|
"apiUrl",
|
|
134
|
+
"basedEnv",
|
|
135
|
+
"basedProject",
|
|
136
|
+
"basedOrg",
|
|
203
137
|
"githubClientId",
|
|
204
138
|
"googleClientId"
|
|
205
139
|
];
|
|
@@ -210,13 +144,11 @@ const getConfig = () => {
|
|
|
210
144
|
);
|
|
211
145
|
}
|
|
212
146
|
if (finalConfig.isDevelopment) {
|
|
213
|
-
console.
|
|
147
|
+
console.log(
|
|
214
148
|
"environment in SDK:",
|
|
215
149
|
env || process.env.NODE_ENV || process.env.NODE_ENV
|
|
216
150
|
);
|
|
217
151
|
console.log(finalConfig);
|
|
218
|
-
} else if (global.window) {
|
|
219
|
-
global.window.finalConfig = finalConfig;
|
|
220
152
|
}
|
|
221
153
|
return finalConfig;
|
|
222
154
|
} catch (error) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -28,48 +28,26 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
28
28
|
var index_exports = {};
|
|
29
29
|
__export(index_exports, {
|
|
30
30
|
SDK: () => SDK,
|
|
31
|
-
|
|
31
|
+
createAIService: () => import_services3.createAIService,
|
|
32
32
|
createAuthService: () => import_services3.createAuthService,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
createFeatureFlagService: () => import_services3.createFeatureFlagService,
|
|
37
|
-
createFileService: () => import_services3.createFileService,
|
|
38
|
-
createIntegrationService: () => import_services3.createIntegrationService,
|
|
39
|
-
createMetricsService: () => import_services3.createMetricsService,
|
|
40
|
-
createPaymentService: () => import_services3.createPaymentService,
|
|
41
|
-
createPlanService: () => import_services3.createPlanService,
|
|
42
|
-
createProjectService: () => import_services3.createProjectService,
|
|
43
|
-
createPullRequestService: () => import_services3.createPullRequestService,
|
|
44
|
-
createSubscriptionService: () => import_services3.createSubscriptionService,
|
|
45
|
-
createTrackingService: () => import_services3.createTrackingService,
|
|
46
|
-
createWaitlistService: () => import_services3.createWaitlistService,
|
|
33
|
+
createCoreService: () => import_services3.createCoreService,
|
|
34
|
+
createSocketService: () => import_services3.createSocketService,
|
|
35
|
+
createSymstoryService: () => import_services3.createSymstoryService,
|
|
47
36
|
default: () => index_default,
|
|
48
|
-
environment: () => import_environment2.default
|
|
49
|
-
isLocalhost: () => isLocalhost
|
|
37
|
+
environment: () => import_environment2.default
|
|
50
38
|
});
|
|
51
39
|
module.exports = __toCommonJS(index_exports);
|
|
52
40
|
var import_services = require("./services/index.js");
|
|
53
41
|
var import_services2 = require("./utils/services.js");
|
|
42
|
+
var import_SymstoryService = require("./services/SymstoryService.js");
|
|
54
43
|
var import_environment = __toESM(require("./config/environment.js"), 1);
|
|
55
|
-
var import_rootEventBus = require("./state/rootEventBus.js");
|
|
56
44
|
var import_services3 = require("./services/index.js");
|
|
57
45
|
var import_environment2 = __toESM(require("./config/environment.js"), 1);
|
|
58
|
-
const isBrowserEnvironment = () => typeof window !== "undefined";
|
|
59
|
-
const isLocalhost = () => {
|
|
60
|
-
if (!isBrowserEnvironment()) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
const host = window.location && window.location.hostname;
|
|
64
|
-
return host === "localhost" || host === "127.0.0.1" || host === "::1" || host === "" || !host;
|
|
65
|
-
};
|
|
66
46
|
class SDK {
|
|
67
47
|
constructor(options = {}) {
|
|
68
48
|
this._services = /* @__PURE__ */ new Map();
|
|
69
49
|
this._context = {};
|
|
70
50
|
this._options = this._validateOptions(options);
|
|
71
|
-
this.environment = import_environment.default;
|
|
72
|
-
this.rootBus = import_rootEventBus.rootBus;
|
|
73
51
|
this._createServiceProxies();
|
|
74
52
|
}
|
|
75
53
|
// Initialize SDK with context
|
|
@@ -87,114 +65,29 @@ class SDK {
|
|
|
87
65
|
})
|
|
88
66
|
),
|
|
89
67
|
this._initService(
|
|
90
|
-
"
|
|
91
|
-
(0, import_services.
|
|
92
|
-
context: this._context,
|
|
93
|
-
options: this._options
|
|
94
|
-
})
|
|
95
|
-
),
|
|
96
|
-
// Initialize new modular services
|
|
97
|
-
this._initService(
|
|
98
|
-
"project",
|
|
99
|
-
(0, import_services.createProjectService)({
|
|
100
|
-
context: this._context,
|
|
101
|
-
options: this._options
|
|
102
|
-
})
|
|
103
|
-
),
|
|
104
|
-
this._initService(
|
|
105
|
-
"plan",
|
|
106
|
-
(0, import_services.createPlanService)({
|
|
107
|
-
context: this._context,
|
|
108
|
-
options: this._options
|
|
109
|
-
})
|
|
110
|
-
),
|
|
111
|
-
this._initService(
|
|
112
|
-
"subscription",
|
|
113
|
-
(0, import_services.createSubscriptionService)({
|
|
68
|
+
"socket",
|
|
69
|
+
(0, import_services.createSocketService)({
|
|
114
70
|
context: this._context,
|
|
115
71
|
options: this._options
|
|
116
72
|
})
|
|
117
73
|
),
|
|
118
74
|
this._initService(
|
|
119
|
-
"
|
|
120
|
-
(0, import_services.
|
|
75
|
+
"symstory",
|
|
76
|
+
(0, import_services.createSymstoryService)({
|
|
121
77
|
context: this._context,
|
|
122
78
|
options: this._options
|
|
123
79
|
})
|
|
124
80
|
),
|
|
125
81
|
this._initService(
|
|
126
|
-
"
|
|
127
|
-
(0, import_services.
|
|
82
|
+
"ai",
|
|
83
|
+
(0, import_services.createAIService)({
|
|
128
84
|
context: this._context,
|
|
129
85
|
options: this._options
|
|
130
86
|
})
|
|
131
87
|
),
|
|
132
88
|
this._initService(
|
|
133
|
-
"
|
|
134
|
-
(0, import_services.
|
|
135
|
-
context: this._context,
|
|
136
|
-
options: this._options
|
|
137
|
-
})
|
|
138
|
-
),
|
|
139
|
-
this._initService(
|
|
140
|
-
"branch",
|
|
141
|
-
(0, import_services.createBranchService)({
|
|
142
|
-
context: this._context,
|
|
143
|
-
options: this._options
|
|
144
|
-
})
|
|
145
|
-
),
|
|
146
|
-
this._initService(
|
|
147
|
-
"pullRequest",
|
|
148
|
-
(0, import_services.createPullRequestService)({
|
|
149
|
-
context: this._context,
|
|
150
|
-
options: this._options
|
|
151
|
-
})
|
|
152
|
-
),
|
|
153
|
-
this._initService(
|
|
154
|
-
"admin",
|
|
155
|
-
(0, import_services.createAdminService)({
|
|
156
|
-
context: this._context,
|
|
157
|
-
options: this._options
|
|
158
|
-
})
|
|
159
|
-
),
|
|
160
|
-
this._initService(
|
|
161
|
-
"screenshot",
|
|
162
|
-
(0, import_services.createScreenshotService)({
|
|
163
|
-
context: this._context,
|
|
164
|
-
options: this._options
|
|
165
|
-
})
|
|
166
|
-
),
|
|
167
|
-
this._initService(
|
|
168
|
-
"tracking",
|
|
169
|
-
(0, import_services.createTrackingService)({
|
|
170
|
-
context: this._context,
|
|
171
|
-
options: this._options
|
|
172
|
-
})
|
|
173
|
-
),
|
|
174
|
-
this._initService(
|
|
175
|
-
"waitlist",
|
|
176
|
-
(0, import_services.createWaitlistService)({
|
|
177
|
-
context: this._context,
|
|
178
|
-
options: this._options
|
|
179
|
-
})
|
|
180
|
-
),
|
|
181
|
-
this._initService(
|
|
182
|
-
"metrics",
|
|
183
|
-
(0, import_services.createMetricsService)({
|
|
184
|
-
context: this._context,
|
|
185
|
-
options: this._options
|
|
186
|
-
})
|
|
187
|
-
),
|
|
188
|
-
this._initService(
|
|
189
|
-
"integration",
|
|
190
|
-
(0, import_services.createIntegrationService)({
|
|
191
|
-
context: this._context,
|
|
192
|
-
options: this._options
|
|
193
|
-
})
|
|
194
|
-
),
|
|
195
|
-
this._initService(
|
|
196
|
-
"featureFlag",
|
|
197
|
-
(0, import_services.createFeatureFlagService)({
|
|
89
|
+
"core",
|
|
90
|
+
(0, import_services.createCoreService)({
|
|
198
91
|
context: this._context,
|
|
199
92
|
options: this._options
|
|
200
93
|
})
|
|
@@ -215,33 +108,16 @@ class SDK {
|
|
|
215
108
|
this._services.set(name, service);
|
|
216
109
|
}
|
|
217
110
|
_validateOptions(options) {
|
|
218
|
-
const onLocalhost = isLocalhost();
|
|
219
|
-
const hasGrafanaUrl = Boolean(import_environment.default.grafanaUrl);
|
|
220
111
|
const defaults = {
|
|
221
112
|
useNewServices: true,
|
|
222
113
|
// Use new service implementations by default
|
|
223
|
-
|
|
114
|
+
baseUrl: import_environment.default.baseUrl,
|
|
224
115
|
socketUrl: import_environment.default.socketUrl,
|
|
225
116
|
timeout: 3e4,
|
|
226
117
|
retryAttempts: 3,
|
|
227
|
-
debug: false
|
|
228
|
-
tracking: {
|
|
229
|
-
// Force-disabled on localhost or when no Grafana URL is configured
|
|
230
|
-
enabled: onLocalhost ? false : hasGrafanaUrl ? import_environment.default.features.trackingEnabled : false
|
|
231
|
-
}
|
|
118
|
+
debug: false
|
|
232
119
|
};
|
|
233
|
-
|
|
234
|
-
...defaults,
|
|
235
|
-
...options,
|
|
236
|
-
tracking: {
|
|
237
|
-
...defaults.tracking,
|
|
238
|
-
...options.tracking || {}
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
if (onLocalhost || !hasGrafanaUrl) {
|
|
242
|
-
merged.tracking.enabled = false;
|
|
243
|
-
}
|
|
244
|
-
return merged;
|
|
120
|
+
return { ...defaults, ...options };
|
|
245
121
|
}
|
|
246
122
|
// Get service instance
|
|
247
123
|
getService(name) {
|
|
@@ -252,19 +128,23 @@ class SDK {
|
|
|
252
128
|
}
|
|
253
129
|
// Update context
|
|
254
130
|
updateContext(newContext) {
|
|
255
|
-
const { ...sanitized } = newContext || {};
|
|
256
131
|
this._context = {
|
|
257
132
|
...this._context,
|
|
258
|
-
...
|
|
133
|
+
...newContext
|
|
259
134
|
};
|
|
260
135
|
for (const service of this._services.values()) {
|
|
261
136
|
service.updateContext(this._context);
|
|
137
|
+
if (service instanceof import_SymstoryService.SymstoryService) {
|
|
138
|
+
service.init();
|
|
139
|
+
}
|
|
262
140
|
}
|
|
263
141
|
}
|
|
264
142
|
// Check if SDK is ready
|
|
265
143
|
isReady() {
|
|
266
144
|
const sdkServices = Array.from(this._services.values());
|
|
267
|
-
return sdkServices.length > 0 && sdkServices.every(
|
|
145
|
+
return sdkServices.length > 0 && sdkServices.every(
|
|
146
|
+
(service) => service.isReady()
|
|
147
|
+
);
|
|
268
148
|
}
|
|
269
149
|
// Get SDK status
|
|
270
150
|
getStatus() {
|