@littlebearapps/create-platform 1.0.0 → 1.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/README.md +98 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +36 -6
- package/dist/prompts.d.ts +14 -2
- package/dist/prompts.js +29 -7
- package/dist/templates.js +78 -0
- package/package.json +3 -2
- package/templates/full/workers/lib/pattern-discovery/ai-prompt.ts +644 -0
- package/templates/full/workers/lib/pattern-discovery/clustering.ts +278 -0
- package/templates/full/workers/lib/pattern-discovery/shadow-evaluation.ts +603 -0
- package/templates/full/workers/lib/pattern-discovery/storage.ts +806 -0
- package/templates/full/workers/lib/pattern-discovery/types.ts +159 -0
- package/templates/full/workers/lib/pattern-discovery/validation.ts +278 -0
- package/templates/full/workers/pattern-discovery.ts +661 -0
- package/templates/full/workers/platform-alert-router.ts +1809 -0
- package/templates/full/workers/platform-notifications.ts +424 -0
- package/templates/full/workers/platform-search.ts +480 -0
- package/templates/full/workers/platform-settings.ts +436 -0
- package/templates/shared/workers/lib/analytics-engine.ts +357 -0
- package/templates/shared/workers/lib/billing.ts +293 -0
- package/templates/shared/workers/lib/circuit-breaker-middleware.ts +25 -0
- package/templates/shared/workers/lib/control.ts +292 -0
- package/templates/shared/workers/lib/economics.ts +368 -0
- package/templates/shared/workers/lib/metrics.ts +103 -0
- package/templates/shared/workers/lib/platform-settings.ts +407 -0
- package/templates/shared/workers/lib/shared/allowances.ts +333 -0
- package/templates/shared/workers/lib/shared/cloudflare.ts +1362 -0
- package/templates/shared/workers/lib/shared/types.ts +58 -0
- package/templates/shared/workers/lib/telemetry-sampling.ts +360 -0
- package/templates/shared/workers/lib/usage/collectors/example.ts +96 -0
- package/templates/shared/workers/lib/usage/collectors/index.ts +128 -0
- package/templates/shared/workers/lib/usage/handlers/audit.ts +306 -0
- package/templates/shared/workers/lib/usage/handlers/backfill.ts +845 -0
- package/templates/shared/workers/lib/usage/handlers/behavioral.ts +429 -0
- package/templates/shared/workers/lib/usage/handlers/data-queries.ts +507 -0
- package/templates/shared/workers/lib/usage/handlers/dlq-admin.ts +364 -0
- package/templates/shared/workers/lib/usage/handlers/health-trends.ts +222 -0
- package/templates/shared/workers/lib/usage/handlers/index.ts +35 -0
- package/templates/shared/workers/lib/usage/handlers/usage-admin.ts +421 -0
- package/templates/shared/workers/lib/usage/handlers/usage-features.ts +1262 -0
- package/templates/shared/workers/lib/usage/handlers/usage-metrics.ts +2420 -0
- package/templates/shared/workers/lib/usage/handlers/usage-settings.ts +610 -0
- package/templates/shared/workers/lib/usage/queue/budget-enforcement.ts +1032 -0
- package/templates/shared/workers/lib/usage/queue/cost-budget-enforcement.ts +128 -0
- package/templates/shared/workers/lib/usage/queue/cost-calculator.ts +77 -0
- package/templates/shared/workers/lib/usage/queue/dlq-handler.ts +161 -0
- package/templates/shared/workers/lib/usage/queue/index.ts +19 -0
- package/templates/shared/workers/lib/usage/queue/telemetry-processor.ts +790 -0
- package/templates/shared/workers/lib/usage/scheduled/anomaly-detection.ts +732 -0
- package/templates/shared/workers/lib/usage/scheduled/data-collection.ts +956 -0
- package/templates/shared/workers/lib/usage/scheduled/error-digest.ts +343 -0
- package/templates/shared/workers/lib/usage/scheduled/index.ts +18 -0
- package/templates/shared/workers/lib/usage/scheduled/rollups.ts +1561 -0
- package/templates/shared/workers/lib/usage/shared/constants.ts +362 -0
- package/templates/shared/workers/lib/usage/shared/index.ts +14 -0
- package/templates/shared/workers/lib/usage/shared/types.ts +1066 -0
- package/templates/shared/workers/lib/usage/shared/utils.ts +795 -0
- package/templates/shared/workers/platform-usage.ts +1915 -0
- package/templates/standard/workers/error-collector.ts +2670 -0
- package/templates/standard/workers/lib/error-collector/capture.ts +213 -0
- package/templates/standard/workers/lib/error-collector/digest.ts +448 -0
- package/templates/standard/workers/lib/error-collector/email-health-alerts.ts +262 -0
- package/templates/standard/workers/lib/error-collector/fingerprint.ts +258 -0
- package/templates/standard/workers/lib/error-collector/gap-alerts.ts +293 -0
- package/templates/standard/workers/lib/error-collector/github.ts +329 -0
- package/templates/standard/workers/lib/error-collector/types.ts +262 -0
- package/templates/standard/workers/lib/sentinel/gap-detection.ts +734 -0
- package/templates/standard/workers/lib/shared/slack-alerts.ts +585 -0
- package/templates/standard/workers/platform-sentinel.ts +1744 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Platform Admin SDK
|
|
2
|
+
|
|
3
|
+
**`@littlebearapps/create-platform`** — Scaffold backend infrastructure for Cloudflare Workers cost protection.
|
|
4
|
+
|
|
5
|
+
Generates workers, D1 migrations, and config files. Run once, then you own the code.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @littlebearapps/create-platform my-platform
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The CLI prompts for:
|
|
14
|
+
- **Project name** and slug
|
|
15
|
+
- **GitHub organisation** (for error collection GitHub issues)
|
|
16
|
+
- **Tier** — how much infrastructure to generate
|
|
17
|
+
- **Gatus URL** (optional) — for heartbeat monitoring
|
|
18
|
+
- **Default assignee** — GitHub username for error issues
|
|
19
|
+
|
|
20
|
+
## Tiers
|
|
21
|
+
|
|
22
|
+
| Tier | Workers | What You Get | Est. Cost |
|
|
23
|
+
|------|---------|-------------|-----------|
|
|
24
|
+
| **Minimal** | 1 | Budget enforcement, circuit breakers, usage telemetry | ~$0/mo |
|
|
25
|
+
| **Standard** | 3 | + Error collector (auto GitHub issues), gap detection sentinel | ~$0/mo |
|
|
26
|
+
| **Full** | 8 | + AI pattern discovery, alert router, notifications, search, settings | ~$5/mo |
|
|
27
|
+
|
|
28
|
+
## What Gets Generated
|
|
29
|
+
|
|
30
|
+
### All tiers
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
my-platform/
|
|
34
|
+
+-- platform/config/
|
|
35
|
+
| +-- services.yaml # Project registry, feature definitions
|
|
36
|
+
| +-- budgets.yaml # Daily limits, circuit breaker thresholds
|
|
37
|
+
+-- storage/d1/migrations/ # D1 schema (4 core migrations + seed)
|
|
38
|
+
+-- workers/
|
|
39
|
+
| +-- platform-usage.ts # Data warehouse worker (cron + queue consumer)
|
|
40
|
+
| +-- lib/ # Shared libraries (billing, analytics, budgets)
|
|
41
|
+
+-- scripts/
|
|
42
|
+
| +-- sync-config.ts # Sync YAML config to D1/KV
|
|
43
|
+
+-- wrangler.*.jsonc # Worker configs with binding placeholders
|
|
44
|
+
+-- package.json
|
|
45
|
+
+-- tsconfig.json
|
|
46
|
+
+-- README.md
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Standard tier adds
|
|
50
|
+
|
|
51
|
+
- `workers/error-collector.ts` — Tail worker that creates GitHub issues from errors
|
|
52
|
+
- `workers/platform-sentinel.ts` — Gap detection, cost monitoring, alerts
|
|
53
|
+
- `workers/lib/error-collector/` — Fingerprinting, deduplication, digest
|
|
54
|
+
- `workers/lib/sentinel/` — Project gap detection
|
|
55
|
+
- `storage/d1/migrations/005_error_collection.sql`
|
|
56
|
+
|
|
57
|
+
### Full tier adds
|
|
58
|
+
|
|
59
|
+
- `workers/pattern-discovery.ts` — AI-assisted transient error pattern discovery
|
|
60
|
+
- `workers/platform-alert-router.ts` — Unified alert normalisation and routing
|
|
61
|
+
- `workers/platform-notifications.ts` — In-app notification API
|
|
62
|
+
- `workers/platform-search.ts` — Full-text search (FTS5)
|
|
63
|
+
- `workers/platform-settings.ts` — Settings management API
|
|
64
|
+
- `workers/lib/pattern-discovery/` — Clustering, AI prompts, validation, shadow eval
|
|
65
|
+
- `storage/d1/migrations/006_pattern_discovery.sql`
|
|
66
|
+
- `storage/d1/migrations/007_notifications_search.sql`
|
|
67
|
+
|
|
68
|
+
## Post-Scaffold Steps
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
cd my-platform
|
|
72
|
+
npm install
|
|
73
|
+
|
|
74
|
+
# Create Cloudflare resources
|
|
75
|
+
npx wrangler d1 create my-platform-metrics
|
|
76
|
+
npx wrangler kv namespace create PLATFORM_CACHE
|
|
77
|
+
npx wrangler queues create my-platform-telemetry
|
|
78
|
+
npx wrangler queues create my-platform-telemetry-dlq
|
|
79
|
+
|
|
80
|
+
# Update resource IDs in wrangler.*.jsonc, then:
|
|
81
|
+
npm run sync:config
|
|
82
|
+
npx wrangler d1 migrations apply my-platform-metrics --remote
|
|
83
|
+
npx wrangler deploy -c wrangler.my-platform-usage.jsonc
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Consumer SDK
|
|
87
|
+
|
|
88
|
+
The generated workers use `@littlebearapps/platform-sdk` — the Consumer SDK. Install it in your application workers:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install @littlebearapps/platform-sdk
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
See the [Consumer SDK README](../sdk/README.md) for integration details.
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
* circuit breakers, and cost protection.
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
|
-
* npx @littlebearapps/create-platform [project-name]
|
|
9
|
+
* npx @littlebearapps/create-platform [project-name] [options]
|
|
10
|
+
*
|
|
11
|
+
* Examples:
|
|
12
|
+
* npx @littlebearapps/create-platform my-project
|
|
13
|
+
* npx @littlebearapps/create-platform my-project --tier full --github-org myorg
|
|
14
|
+
* npx @littlebearapps/create-platform my-project --tier minimal --skip-prompts
|
|
10
15
|
*/
|
|
11
16
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -6,20 +6,50 @@
|
|
|
6
6
|
* circuit breakers, and cost protection.
|
|
7
7
|
*
|
|
8
8
|
* Usage:
|
|
9
|
-
* npx @littlebearapps/create-platform [project-name]
|
|
9
|
+
* npx @littlebearapps/create-platform [project-name] [options]
|
|
10
|
+
*
|
|
11
|
+
* Examples:
|
|
12
|
+
* npx @littlebearapps/create-platform my-project
|
|
13
|
+
* npx @littlebearapps/create-platform my-project --tier full --github-org myorg
|
|
14
|
+
* npx @littlebearapps/create-platform my-project --tier minimal --skip-prompts
|
|
10
15
|
*/
|
|
11
16
|
import { resolve } from 'node:path';
|
|
17
|
+
import { Command } from 'commander';
|
|
12
18
|
import pc from 'picocolors';
|
|
13
|
-
import { collectOptions } from './prompts.js';
|
|
19
|
+
import { collectOptions, isValidTier } from './prompts.js';
|
|
14
20
|
import { scaffold } from './scaffold.js';
|
|
15
21
|
const BANNER = `
|
|
16
|
-
${pc.bold(pc.cyan('Platform SDK'))} — Cloudflare Cost Protection
|
|
17
|
-
${pc.dim('
|
|
22
|
+
${pc.bold(pc.cyan('Platform Admin SDK'))} — Cloudflare Cost Protection
|
|
23
|
+
${pc.dim('Scaffold backend infrastructure: circuit breakers, budget enforcement, error collection')}
|
|
18
24
|
`;
|
|
25
|
+
const program = new Command()
|
|
26
|
+
.name('create-platform')
|
|
27
|
+
.description('Scaffold a Cloudflare Workers platform with SDK integration')
|
|
28
|
+
.version('1.1.0')
|
|
29
|
+
.argument('[project-name]', 'Name of the project to create')
|
|
30
|
+
.option('--tier <tier>', 'Infrastructure tier (minimal, standard, full)')
|
|
31
|
+
.option('--github-org <org>', 'GitHub organisation for error issue creation')
|
|
32
|
+
.option('--gatus-url <url>', 'Gatus status page URL for heartbeat monitoring')
|
|
33
|
+
.option('--default-assignee <user>', 'Default GitHub assignee for error issues')
|
|
34
|
+
.option('--skip-prompts', 'Non-interactive mode — fail if required flags are missing');
|
|
19
35
|
async function main() {
|
|
20
36
|
console.log(BANNER);
|
|
21
|
-
|
|
22
|
-
const
|
|
37
|
+
program.parse();
|
|
38
|
+
const opts = program.opts();
|
|
39
|
+
const [projectNameArg] = program.args;
|
|
40
|
+
// Validate tier if provided
|
|
41
|
+
if (opts.tier && !isValidTier(opts.tier)) {
|
|
42
|
+
console.error(pc.red(` Error: Invalid tier "${opts.tier}". Must be one of: minimal, standard, full`));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
const options = await collectOptions({
|
|
46
|
+
projectName: projectNameArg,
|
|
47
|
+
tier: opts.tier,
|
|
48
|
+
githubOrg: opts.githubOrg,
|
|
49
|
+
gatusUrl: opts.gatusUrl,
|
|
50
|
+
defaultAssignee: opts.defaultAssignee,
|
|
51
|
+
skipPrompts: opts.skipPrompts,
|
|
52
|
+
});
|
|
23
53
|
const outputDir = resolve(process.cwd(), options.projectName);
|
|
24
54
|
console.log();
|
|
25
55
|
console.log(` ${pc.bold('Project')}: ${options.projectName}`);
|
package/dist/prompts.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Interactive CLI prompts for project scaffolding configuration.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* When flags are provided via CLI, those values are used without prompting.
|
|
5
|
+
* Falls back to interactive prompts for missing values, or sensible defaults
|
|
6
|
+
* when running non-interactively.
|
|
5
7
|
*/
|
|
6
8
|
export type Tier = 'minimal' | 'standard' | 'full';
|
|
7
9
|
export interface ScaffoldOptions {
|
|
@@ -12,4 +14,14 @@ export interface ScaffoldOptions {
|
|
|
12
14
|
gatusUrl: string;
|
|
13
15
|
defaultAssignee: string;
|
|
14
16
|
}
|
|
15
|
-
|
|
17
|
+
/** Pre-filled values from CLI flags. */
|
|
18
|
+
export interface CLIFlags {
|
|
19
|
+
projectName?: string;
|
|
20
|
+
tier?: Tier;
|
|
21
|
+
githubOrg?: string;
|
|
22
|
+
gatusUrl?: string;
|
|
23
|
+
defaultAssignee?: string;
|
|
24
|
+
skipPrompts?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function isValidTier(value: string): value is Tier;
|
|
27
|
+
export declare function collectOptions(flags?: CLIFlags): Promise<ScaffoldOptions>;
|
package/dist/prompts.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Interactive CLI prompts for project scaffolding configuration.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* When flags are provided via CLI, those values are used without prompting.
|
|
5
|
+
* Falls back to interactive prompts for missing values, or sensible defaults
|
|
6
|
+
* when running non-interactively.
|
|
5
7
|
*/
|
|
6
8
|
import * as readline from 'node:readline';
|
|
9
|
+
const VALID_TIERS = ['minimal', 'standard', 'full'];
|
|
10
|
+
export function isValidTier(value) {
|
|
11
|
+
return VALID_TIERS.includes(value);
|
|
12
|
+
}
|
|
7
13
|
function slugify(name) {
|
|
8
14
|
return name
|
|
9
15
|
.toLowerCase()
|
|
@@ -40,13 +46,29 @@ async function promptSelect(question, options, defaultIndex = 0) {
|
|
|
40
46
|
const idx = parseInt(answer, 10) - 1;
|
|
41
47
|
return options[idx] ?? options[defaultIndex];
|
|
42
48
|
}
|
|
43
|
-
export async function collectOptions(
|
|
44
|
-
|
|
49
|
+
export async function collectOptions(flags = {}) {
|
|
50
|
+
if (flags.skipPrompts) {
|
|
51
|
+
if (!flags.projectName) {
|
|
52
|
+
throw new Error('--skip-prompts requires a project name argument');
|
|
53
|
+
}
|
|
54
|
+
if (!flags.tier) {
|
|
55
|
+
throw new Error('--skip-prompts requires --tier');
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
projectName: flags.projectName,
|
|
59
|
+
projectSlug: slugify(flags.projectName),
|
|
60
|
+
githubOrg: flags.githubOrg ?? '',
|
|
61
|
+
tier: flags.tier,
|
|
62
|
+
gatusUrl: flags.gatusUrl ?? '',
|
|
63
|
+
defaultAssignee: flags.defaultAssignee ?? '',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const projectName = flags.projectName || await prompt('Project name', 'my-platform');
|
|
45
67
|
const projectSlug = await prompt('Project slug (for resource names)', slugify(projectName));
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const gatusUrl = await prompt('Gatus status page URL (optional)', '');
|
|
49
|
-
const defaultAssignee = await prompt('Default GitHub assignee (optional)', '');
|
|
68
|
+
const tier = flags.tier || await promptSelect('Setup tier:', VALID_TIERS, 1);
|
|
69
|
+
const githubOrg = flags.githubOrg ?? await prompt('GitHub org (for error issue creation)', '');
|
|
70
|
+
const gatusUrl = flags.gatusUrl ?? await prompt('Gatus status page URL (optional)', '');
|
|
71
|
+
const defaultAssignee = flags.defaultAssignee ?? await prompt('Default GitHub assignee (optional)', '');
|
|
50
72
|
return {
|
|
51
73
|
projectName,
|
|
52
74
|
projectSlug,
|
package/dist/templates.js
CHANGED
|
@@ -22,6 +22,54 @@ const SHARED_FILES = [
|
|
|
22
22
|
{ src: 'shared/package.json.hbs', dest: 'package.json', template: true },
|
|
23
23
|
{ src: 'shared/tsconfig.json', dest: 'tsconfig.json', template: false },
|
|
24
24
|
{ src: 'shared/README.md.hbs', dest: 'README.md', template: true },
|
|
25
|
+
// Workers — platform-usage (data warehouse, cron + queue consumer)
|
|
26
|
+
{ src: 'shared/workers/platform-usage.ts', dest: 'workers/platform-usage.ts', template: false },
|
|
27
|
+
// Workers — root lib (shared utilities)
|
|
28
|
+
{ src: 'shared/workers/lib/billing.ts', dest: 'workers/lib/billing.ts', template: false },
|
|
29
|
+
{ src: 'shared/workers/lib/economics.ts', dest: 'workers/lib/economics.ts', template: false },
|
|
30
|
+
{ src: 'shared/workers/lib/analytics-engine.ts', dest: 'workers/lib/analytics-engine.ts', template: false },
|
|
31
|
+
{ src: 'shared/workers/lib/platform-settings.ts', dest: 'workers/lib/platform-settings.ts', template: false },
|
|
32
|
+
{ src: 'shared/workers/lib/circuit-breaker-middleware.ts', dest: 'workers/lib/circuit-breaker-middleware.ts', template: false },
|
|
33
|
+
{ src: 'shared/workers/lib/metrics.ts', dest: 'workers/lib/metrics.ts', template: false },
|
|
34
|
+
{ src: 'shared/workers/lib/telemetry-sampling.ts', dest: 'workers/lib/telemetry-sampling.ts', template: false },
|
|
35
|
+
{ src: 'shared/workers/lib/control.ts', dest: 'workers/lib/control.ts', template: false },
|
|
36
|
+
// Workers — lib/shared (cross-boundary types and utilities)
|
|
37
|
+
{ src: 'shared/workers/lib/shared/types.ts', dest: 'workers/lib/shared/types.ts', template: false },
|
|
38
|
+
{ src: 'shared/workers/lib/shared/allowances.ts', dest: 'workers/lib/shared/allowances.ts', template: false },
|
|
39
|
+
{ src: 'shared/workers/lib/shared/cloudflare.ts', dest: 'workers/lib/shared/cloudflare.ts', template: false },
|
|
40
|
+
// Workers — lib/usage/shared
|
|
41
|
+
{ src: 'shared/workers/lib/usage/shared/types.ts', dest: 'workers/lib/usage/shared/types.ts', template: false },
|
|
42
|
+
{ src: 'shared/workers/lib/usage/shared/constants.ts', dest: 'workers/lib/usage/shared/constants.ts', template: false },
|
|
43
|
+
{ src: 'shared/workers/lib/usage/shared/utils.ts', dest: 'workers/lib/usage/shared/utils.ts', template: false },
|
|
44
|
+
{ src: 'shared/workers/lib/usage/shared/index.ts', dest: 'workers/lib/usage/shared/index.ts', template: false },
|
|
45
|
+
// Workers — lib/usage/handlers
|
|
46
|
+
{ src: 'shared/workers/lib/usage/handlers/index.ts', dest: 'workers/lib/usage/handlers/index.ts', template: false },
|
|
47
|
+
{ src: 'shared/workers/lib/usage/handlers/data-queries.ts', dest: 'workers/lib/usage/handlers/data-queries.ts', template: false },
|
|
48
|
+
{ src: 'shared/workers/lib/usage/handlers/usage-metrics.ts', dest: 'workers/lib/usage/handlers/usage-metrics.ts', template: false },
|
|
49
|
+
{ src: 'shared/workers/lib/usage/handlers/usage-features.ts', dest: 'workers/lib/usage/handlers/usage-features.ts', template: false },
|
|
50
|
+
{ src: 'shared/workers/lib/usage/handlers/usage-settings.ts', dest: 'workers/lib/usage/handlers/usage-settings.ts', template: false },
|
|
51
|
+
{ src: 'shared/workers/lib/usage/handlers/usage-admin.ts', dest: 'workers/lib/usage/handlers/usage-admin.ts', template: false },
|
|
52
|
+
{ src: 'shared/workers/lib/usage/handlers/dlq-admin.ts', dest: 'workers/lib/usage/handlers/dlq-admin.ts', template: false },
|
|
53
|
+
{ src: 'shared/workers/lib/usage/handlers/health-trends.ts', dest: 'workers/lib/usage/handlers/health-trends.ts', template: false },
|
|
54
|
+
{ src: 'shared/workers/lib/usage/handlers/backfill.ts', dest: 'workers/lib/usage/handlers/backfill.ts', template: false },
|
|
55
|
+
{ src: 'shared/workers/lib/usage/handlers/audit.ts', dest: 'workers/lib/usage/handlers/audit.ts', template: false },
|
|
56
|
+
{ src: 'shared/workers/lib/usage/handlers/behavioral.ts', dest: 'workers/lib/usage/handlers/behavioral.ts', template: false },
|
|
57
|
+
// Workers — lib/usage/queue
|
|
58
|
+
{ src: 'shared/workers/lib/usage/queue/index.ts', dest: 'workers/lib/usage/queue/index.ts', template: false },
|
|
59
|
+
{ src: 'shared/workers/lib/usage/queue/telemetry-processor.ts', dest: 'workers/lib/usage/queue/telemetry-processor.ts', template: false },
|
|
60
|
+
{ src: 'shared/workers/lib/usage/queue/dlq-handler.ts', dest: 'workers/lib/usage/queue/dlq-handler.ts', template: false },
|
|
61
|
+
{ src: 'shared/workers/lib/usage/queue/budget-enforcement.ts', dest: 'workers/lib/usage/queue/budget-enforcement.ts', template: false },
|
|
62
|
+
{ src: 'shared/workers/lib/usage/queue/cost-calculator.ts', dest: 'workers/lib/usage/queue/cost-calculator.ts', template: false },
|
|
63
|
+
{ src: 'shared/workers/lib/usage/queue/cost-budget-enforcement.ts', dest: 'workers/lib/usage/queue/cost-budget-enforcement.ts', template: false },
|
|
64
|
+
// Workers — lib/usage/scheduled
|
|
65
|
+
{ src: 'shared/workers/lib/usage/scheduled/index.ts', dest: 'workers/lib/usage/scheduled/index.ts', template: false },
|
|
66
|
+
{ src: 'shared/workers/lib/usage/scheduled/data-collection.ts', dest: 'workers/lib/usage/scheduled/data-collection.ts', template: false },
|
|
67
|
+
{ src: 'shared/workers/lib/usage/scheduled/anomaly-detection.ts', dest: 'workers/lib/usage/scheduled/anomaly-detection.ts', template: false },
|
|
68
|
+
{ src: 'shared/workers/lib/usage/scheduled/rollups.ts', dest: 'workers/lib/usage/scheduled/rollups.ts', template: false },
|
|
69
|
+
{ src: 'shared/workers/lib/usage/scheduled/error-digest.ts', dest: 'workers/lib/usage/scheduled/error-digest.ts', template: false },
|
|
70
|
+
// Workers — lib/usage/collectors (pluggable interface + example)
|
|
71
|
+
{ src: 'shared/workers/lib/usage/collectors/index.ts', dest: 'workers/lib/usage/collectors/index.ts', template: false },
|
|
72
|
+
{ src: 'shared/workers/lib/usage/collectors/example.ts', dest: 'workers/lib/usage/collectors/example.ts', template: false },
|
|
25
73
|
];
|
|
26
74
|
const STANDARD_FILES = [
|
|
27
75
|
// Additional migrations
|
|
@@ -29,6 +77,20 @@ const STANDARD_FILES = [
|
|
|
29
77
|
// Wrangler configs
|
|
30
78
|
{ src: 'standard/wrangler.error-collector.jsonc.hbs', dest: 'wrangler.{{projectSlug}}-error-collector.jsonc', template: true },
|
|
31
79
|
{ src: 'standard/wrangler.sentinel.jsonc.hbs', dest: 'wrangler.{{projectSlug}}-sentinel.jsonc', template: true },
|
|
80
|
+
// Workers — error-collector (tail worker → GitHub issues)
|
|
81
|
+
{ src: 'standard/workers/error-collector.ts', dest: 'workers/error-collector.ts', template: false },
|
|
82
|
+
{ src: 'standard/workers/lib/error-collector/capture.ts', dest: 'workers/lib/error-collector/capture.ts', template: false },
|
|
83
|
+
{ src: 'standard/workers/lib/error-collector/fingerprint.ts', dest: 'workers/lib/error-collector/fingerprint.ts', template: false },
|
|
84
|
+
{ src: 'standard/workers/lib/error-collector/types.ts', dest: 'workers/lib/error-collector/types.ts', template: false },
|
|
85
|
+
{ src: 'standard/workers/lib/error-collector/github.ts', dest: 'workers/lib/error-collector/github.ts', template: false },
|
|
86
|
+
{ src: 'standard/workers/lib/error-collector/digest.ts', dest: 'workers/lib/error-collector/digest.ts', template: false },
|
|
87
|
+
{ src: 'standard/workers/lib/error-collector/gap-alerts.ts', dest: 'workers/lib/error-collector/gap-alerts.ts', template: false },
|
|
88
|
+
{ src: 'standard/workers/lib/error-collector/email-health-alerts.ts', dest: 'workers/lib/error-collector/email-health-alerts.ts', template: false },
|
|
89
|
+
// Workers — platform-sentinel (gap detection, cost monitoring)
|
|
90
|
+
{ src: 'standard/workers/platform-sentinel.ts', dest: 'workers/platform-sentinel.ts', template: false },
|
|
91
|
+
{ src: 'standard/workers/lib/sentinel/gap-detection.ts', dest: 'workers/lib/sentinel/gap-detection.ts', template: false },
|
|
92
|
+
// Workers — shared lib (used by standard-tier workers)
|
|
93
|
+
{ src: 'standard/workers/lib/shared/slack-alerts.ts', dest: 'workers/lib/shared/slack-alerts.ts', template: false },
|
|
32
94
|
];
|
|
33
95
|
const FULL_FILES = [
|
|
34
96
|
// Additional migrations
|
|
@@ -40,6 +102,22 @@ const FULL_FILES = [
|
|
|
40
102
|
{ src: 'full/wrangler.notifications.jsonc.hbs', dest: 'wrangler.{{projectSlug}}-notifications.jsonc', template: true },
|
|
41
103
|
{ src: 'full/wrangler.search.jsonc.hbs', dest: 'wrangler.{{projectSlug}}-search.jsonc', template: true },
|
|
42
104
|
{ src: 'full/wrangler.settings.jsonc.hbs', dest: 'wrangler.{{projectSlug}}-settings.jsonc', template: true },
|
|
105
|
+
// Workers — pattern-discovery (AI-assisted transient error patterns)
|
|
106
|
+
{ src: 'full/workers/pattern-discovery.ts', dest: 'workers/pattern-discovery.ts', template: false },
|
|
107
|
+
{ src: 'full/workers/lib/pattern-discovery/types.ts', dest: 'workers/lib/pattern-discovery/types.ts', template: false },
|
|
108
|
+
{ src: 'full/workers/lib/pattern-discovery/clustering.ts', dest: 'workers/lib/pattern-discovery/clustering.ts', template: false },
|
|
109
|
+
{ src: 'full/workers/lib/pattern-discovery/ai-prompt.ts', dest: 'workers/lib/pattern-discovery/ai-prompt.ts', template: false },
|
|
110
|
+
{ src: 'full/workers/lib/pattern-discovery/storage.ts', dest: 'workers/lib/pattern-discovery/storage.ts', template: false },
|
|
111
|
+
{ src: 'full/workers/lib/pattern-discovery/validation.ts', dest: 'workers/lib/pattern-discovery/validation.ts', template: false },
|
|
112
|
+
{ src: 'full/workers/lib/pattern-discovery/shadow-evaluation.ts', dest: 'workers/lib/pattern-discovery/shadow-evaluation.ts', template: false },
|
|
113
|
+
// Workers — platform-alert-router (unified alert normalisation)
|
|
114
|
+
{ src: 'full/workers/platform-alert-router.ts', dest: 'workers/platform-alert-router.ts', template: false },
|
|
115
|
+
// Workers — platform-notifications (in-app notification API)
|
|
116
|
+
{ src: 'full/workers/platform-notifications.ts', dest: 'workers/platform-notifications.ts', template: false },
|
|
117
|
+
// Workers — platform-search (full-text search FTS5)
|
|
118
|
+
{ src: 'full/workers/platform-search.ts', dest: 'workers/platform-search.ts', template: false },
|
|
119
|
+
// Workers — platform-settings (settings management API)
|
|
120
|
+
{ src: 'full/workers/platform-settings.ts', dest: 'workers/platform-settings.ts', template: false },
|
|
43
121
|
];
|
|
44
122
|
export function getFilesForTier(tier) {
|
|
45
123
|
const files = [...SHARED_FILES];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@littlebearapps/create-platform",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Platform Admin SDK — scaffold backend infrastructure with workers, circuit breakers, and cost protection for Cloudflare",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"create-platform": "./dist/index.js"
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"prepublishOnly": "npm run build"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"commander": "^14.0.3",
|
|
20
21
|
"handlebars": "^4.7.8",
|
|
21
22
|
"picocolors": "^1.1.1"
|
|
22
23
|
},
|