Skip to content

Commit abd0517

Browse files
Copilothotlong
andcommitted
fix: align documentation with actual source APIs and fix template code issues
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent ea7193e commit abd0517

9 files changed

Lines changed: 116 additions & 76 deletions

File tree

apps/docs/app/docs/[[...slug]]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default async function Page(props: PageProps<'/docs/[[...slug]]'>) {
2323
<ViewOptions
2424
markdownUrl={`${page.url}.mdx`}
2525
// update it to match your repo
26-
githubUrl={`https://github.com/${gitConfig.user}/${gitConfig.repo}/blob/${gitConfig.branch}/content/docs/${page.path}`}
26+
githubUrl={`https://github.com/${gitConfig.user}/${gitConfig.repo}/blob/${gitConfig.branch}/apps/docs/content/docs/${page.path}`}
2727
/>
2828
</div>
2929
<DocsBody>

apps/docs/app/og/docs/[...slug]/route.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export async function GET(_req: Request, { params }: RouteContext<'/og/docs/[...
2121

2222
export function generateStaticParams() {
2323
return source.getPages().map((page) => ({
24-
lang: page.locale,
2524
slug: getPageImage(page).segments,
2625
}));
2726
}

apps/docs/components/ai/page-actions.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,13 @@ export function LLMCopyButton({
2424
setLoading(true);
2525

2626
try {
27-
await navigator.clipboard.write([
28-
new ClipboardItem({
29-
'text/plain': fetch(markdownUrl).then(async (res) => {
30-
const content = await res.text();
31-
cache.set(markdownUrl, content);
32-
33-
return content;
34-
}),
35-
}),
36-
]);
27+
const res = await fetch(markdownUrl);
28+
if (!res.ok) {
29+
throw new Error(`Failed to fetch markdown: ${res.status}`);
30+
}
31+
const content = await res.text();
32+
cache.set(markdownUrl, content);
33+
await navigator.clipboard.writeText(content);
3734
} finally {
3835
setLoading(false);
3936
}

apps/docs/content/docs/libraries/auth.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ setObjectStackApiUrl('https://your-server.objectstack.com');
2121
const client = createObjectStackClient(authToken);
2222

2323
// Retrieve existing singleton
24-
const client = getObjectStackClient();
24+
const existingClient = getObjectStackClient();
2525
```
2626

2727
## auth-client.ts

apps/docs/content/docs/libraries/data.mdx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,22 @@ Write-ahead sync queue for offline mutations. Entries are stored in SQLite and p
2525

2626
```ts
2727
interface SyncQueueEntry {
28-
id: string;
28+
id: number;
2929
objectName: string;
30+
recordId: string;
3031
operation: 'create' | 'update' | 'delete';
31-
recordId?: string;
32-
payload: Record<string, unknown>;
32+
payload: string; // JSON-encoded
3333
status: 'pending' | 'in_progress' | 'failed' | 'conflict';
34-
retryCount: number;
35-
createdAt: number;
34+
retries: number;
35+
errorMessage: string | null;
36+
createdAt: number; // timestamp (ms)
37+
updatedAt: number; // timestamp (ms)
3638
}
3739

3840
interface ConflictInfo {
39-
localVersion: Record<string, unknown>;
40-
serverVersion: Record<string, unknown>;
41-
conflictFields: string[];
41+
entry: SyncQueueEntry;
42+
serverRecord: Record<string, unknown> | null;
43+
localRecord: Record<string, unknown> | null;
4244
}
4345
```
4446

@@ -82,14 +84,14 @@ Uses `expo-background-fetch` and `expo-task-manager` to drain the sync queue whe
8284
ObjectQL filter AST helpers for building typed query filters.
8385

8486
```ts
85-
import { OPERATOR_META } from '@/lib/query-builder';
86-
87-
// Available operators with metadata
88-
OPERATOR_META = {
89-
eq: { label: 'Equals', types: ['text', 'number', 'date', ...] },
90-
neq: { label: 'Not Equals', types: ['text', 'number', 'date', ...] },
91-
contains: { label: 'Contains', types: ['text'] },
92-
between: { label: 'Between', types: ['number', 'date'] },
93-
// ... more operators
94-
};
87+
import { OPERATOR_META, operatorsForFieldType } from '@/lib/query-builder';
88+
89+
// Read operator metadata (exported as a const)
90+
OPERATOR_META.eq; // { label: 'equals', valueCount: 1 }
91+
OPERATOR_META.between; // { label: 'is between', valueCount: 2 }
92+
OPERATOR_META.is_null; // { label: 'is empty', valueCount: 0 }
93+
94+
// Get valid operators for a field type
95+
const ops = operatorsForFieldType('text');
96+
// ['eq', 'neq', 'is_null', 'is_not_null', 'contains', 'not_contains', 'starts_with', 'ends_with', 'in', 'not_in']
9597
```

apps/docs/content/docs/libraries/monitoring.mdx

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { createAnalyticsTracker } from '@/lib/analytics';
2929
const tracker = createAnalyticsTracker({
3030
endpoint: 'https://analytics.objectstack.com/events',
3131
batchSize: 20,
32-
flushInterval: 30000, // 30 seconds
32+
flushIntervalMs: 30_000, // 30 seconds
3333
});
3434

3535
// Track events (queued and flushed in batches)
@@ -56,21 +56,33 @@ try {
5656
}
5757
```
5858

59-
Error codes: `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `VALIDATION`, `CONFLICT`, `RATE_LIMITED`, `SERVER_ERROR`, `NETWORK_ERROR`, `TIMEOUT`.
59+
Error codes: `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `VALIDATION_ERROR`, `CONFLICT`, `RATE_LIMITED`, `INTERNAL_ERROR`, `NETWORK_ERROR`, `TIMEOUT`.
6060

6161
## performance-benchmark.ts
6262

6363
Performance metric tracking with configurable thresholds.
6464

6565
```ts
66-
import type { BenchmarkConfig } from '@/lib/performance-benchmark';
67-
68-
const config: BenchmarkConfig = {
69-
appStartup: { threshold: 2000 }, // 2s max
70-
screenRender: { threshold: 500 }, // 500ms max
71-
apiResponse: { threshold: 3000 }, // 3s max
72-
frameTime: { threshold: 16.67 }, // 60fps target
73-
};
66+
import { createPerformanceBenchmark } from '@/lib/performance-benchmark';
67+
68+
const bench = createPerformanceBenchmark({
69+
appStartup: 2000, // 2s max
70+
screenRender: 500, // 500ms max
71+
apiResponse: 3000, // 3s max
72+
frameTime: 16.67, // 60fps target
73+
});
74+
75+
// Record a measurement
76+
bench.measure('login-api', 450, 'apiResponse');
77+
78+
// Time an async operation
79+
const { result, measurement } = await bench.timeAsync(
80+
'fetch-contacts', () => fetchContacts(), 'apiResponse',
81+
);
82+
83+
// Get aggregate report
84+
const report = bench.getReport();
85+
// { measurements, thresholds, passedCount, failedCount, passRate }
7486
```
7587

7688
## memory-profiler.ts
@@ -80,16 +92,19 @@ Memory leak detection for development builds.
8092
```ts
8193
import { createMemoryTracker } from '@/lib/memory-profiler';
8294

83-
const tracker = createMemoryTracker({
84-
leakThreshold: 10, // Report after 10 unmatched mounts
85-
});
95+
const tracker = createMemoryTracker();
96+
97+
// Register a resource (component mount, subscription, etc.)
98+
tracker.track('ContactList', () => cleanup());
99+
100+
// Unregister when done (component unmount, unsubscribe)
101+
tracker.untrack('ContactList');
86102

87-
// Track component lifecycle
88-
tracker.onMount('ContactList');
89-
tracker.onUnmount('ContactList');
103+
// Report entries tracked longer than 30s (potential leaks)
104+
const leaks = tracker.reportLeaks(30_000);
90105

91-
// Check for leaks
92-
const leaks = tracker.getLeaks();
106+
// Clean up all tracked entries
107+
tracker.disposeAll();
93108
```
94109

95-
Tracks component mounts, subscriptions, and event listeners. Reports potential memory leaks when unmount counts don't match mount counts above a configurable threshold.
110+
Tracks component mounts, subscriptions, and event listeners. Entries that remain tracked beyond the threshold are reported as potential leaks in development builds.

apps/docs/content/docs/libraries/security.mdx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,43 @@ import {
1313
validateCertificatePin,
1414
} from '@/lib/certificate-pinning';
1515

16-
// Build a pinning policy
17-
const policy = buildPinningPolicy({
18-
hostname: 'api.objectstack.com',
19-
pins: ['sha256/AAAA...', 'sha256/BBBB...'],
20-
});
21-
22-
// Validate during network requests
23-
const isValid = await validateCertificatePin(policy);
16+
// Build a pinning policy from the API base URL
17+
const policy = buildPinningPolicy(
18+
'https://api.objectstack.com',
19+
['sha256/AAAA...', 'sha256/BBBB...'],
20+
);
21+
// Returns: { hostname, pins, enforced: true, maxChainLength: 3 }
22+
23+
// Validate a certificate hash against the policy
24+
const isValid = validateCertificatePin(policy, 'sha256/AAAA...');
2425
```
2526

2627
## security-audit.ts
2728

2829
Pre-release security checklist and audit report generator.
2930

3031
```ts
31-
import { createSecurityAudit } from '@/lib/security-audit';
32+
import { createSecurityAudit, getDefaultSecurityChecks } from '@/lib/security-audit';
3233

3334
const audit = createSecurityAudit();
3435

35-
// Register checks
36-
audit.addCheck('https-enforced', () => checkHTTPS());
37-
audit.addCheck('cert-pinning', () => checkCertPinning());
38-
audit.addCheck('secure-storage', () => checkSecureStorage());
36+
// Register checks using the AuditCheckDefinition shape
37+
audit.addCheck({
38+
id: 'https-only',
39+
description: 'API communication uses HTTPS',
40+
severity: 'critical',
41+
evaluate: () => apiUrl.startsWith('https://'),
42+
failureDetail: 'All API communication must use HTTPS.',
43+
});
44+
45+
// Or use the built-in check set
46+
for (const check of getDefaultSecurityChecks({ httpsOnly: true, biometricEnabled: true })) {
47+
audit.addCheck(check);
48+
}
3949

4050
// Generate report
4151
const report = await audit.run();
42-
// { passed: ['https-enforced', ...], failed: [...], score: 0.95 }
52+
// { checks: AuditCheckResult[], passedCount, failedCount, score: 0–100 }
4353
```
4454

4555
## app-lock.ts

apps/docs/content/docs/libraries/utilities.mdx

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,22 @@ Feature flag manager with A/B testing support.
5050
import { createFeatureFlagManager } from '@/lib/feature-flags';
5151

5252
const manager = createFeatureFlagManager({
53-
flags: {
54-
'new-dashboard': { enabled: true, rollout: 50 },
55-
'ai-search': { enabled: false },
56-
},
53+
endpoint: 'https://server.objectstack.com/flags',
54+
refreshIntervalMs: 300_000, // 5 minutes
55+
defaults: [
56+
{ key: 'new-dashboard', enabled: true, rolloutPercentage: 50 },
57+
{ key: 'ai-search', enabled: false },
58+
],
5759
});
5860

59-
// Evaluate a flag (considers rollout percentage)
60-
const isEnabled = manager.evaluate('new-dashboard', userId);
61+
// Set user for rollout bucketing
62+
manager.setUserId(userId);
63+
64+
// Evaluate a flag (considers rolloutPercentage)
65+
const enabled = manager.isEnabled('new-dashboard');
66+
67+
// Start periodic refresh
68+
manager.startPolling();
6169
```
6270

6371
Uses `hashUserToPercentage()` for deterministic percentage-based bucketing.
@@ -71,25 +79,30 @@ import { createRemoteConfigManager } from '@/lib/remote-config';
7179

7280
const config = createRemoteConfigManager({
7381
endpoint: 'https://server.objectstack.com/config',
74-
pollInterval: 300000, // 5 minutes
82+
refreshIntervalMs: 600_000, // 10 minutes
83+
defaults: { maxUploadSizeMB: 10 },
7584
});
7685

7786
// Fetch latest config
7887
await config.refresh();
7988

8089
// Get a value (falls back to cached)
81-
const value = config.get('maxUploadSizeMB'); // 10
90+
const value = config.getValue<number>('maxUploadSizeMB');
91+
92+
// Get with fallback
93+
const limit = config.getValueWithDefault('maxUploadSizeMB', 10);
8294
```
8395

8496
## app-store-review.ts
8597

86-
App Store submission checklist validation.
98+
App Store submission checklist validation against Expo app config.
8799

88100
```ts
89-
import type { ReviewChecklist } from '@/lib/app-store-review';
101+
import { validateAppStoreReadiness } from '@/lib/app-store-review';
102+
import type { AppConfig, ReviewReport, ReviewCheckItem } from '@/lib/app-store-review';
90103

91-
// Validates against expo app.json config
92-
// Checks: metadata, assets, privacy, compliance
104+
const report: ReviewReport = validateAppStoreReadiness(appConfig);
105+
// { checks: ReviewCheckItem[], passedCount, failedCount, readiness: 0–100 }
93106
```
94107

95108
## utils.ts

apps/docs/next.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ const config = {
77
reactStrictMode: true,
88
async rewrites() {
99
return [
10+
{
11+
source: '/docs.mdx',
12+
destination: '/llms.mdx/docs',
13+
},
1014
{
1115
source: '/docs/:path*.mdx',
1216
destination: '/llms.mdx/docs/:path*',

0 commit comments

Comments
 (0)