@cotrrackpro-dev/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/assistant/compliance.d.ts +24 -0
- package/dist/assistant/compliance.js +60 -0
- package/dist/assistant/compliance.js.map +1 -0
- package/dist/assistant/crisis.d.ts +31 -0
- package/dist/assistant/crisis.js +62 -0
- package/dist/assistant/crisis.js.map +1 -0
- package/dist/assistant/index.d.ts +15 -0
- package/dist/assistant/index.js +16 -0
- package/dist/assistant/index.js.map +1 -0
- package/dist/assistant/levels.d.ts +43 -0
- package/dist/assistant/levels.js +102 -0
- package/dist/assistant/levels.js.map +1 -0
- package/dist/assistant/prompt.d.ts +20 -0
- package/dist/assistant/prompt.js +96 -0
- package/dist/assistant/prompt.js.map +1 -0
- package/dist/assistant/rbac.d.ts +45 -0
- package/dist/assistant/rbac.js +75 -0
- package/dist/assistant/rbac.js.map +1 -0
- package/dist/assistant/readability.d.ts +28 -0
- package/dist/assistant/readability.js +70 -0
- package/dist/assistant/readability.js.map +1 -0
- package/dist/auth/broker.d.ts +32 -0
- package/dist/auth/broker.js +48 -0
- package/dist/auth/broker.js.map +1 -0
- package/dist/auth/deviceFlow.d.ts +26 -0
- package/dist/auth/deviceFlow.js +65 -0
- package/dist/auth/deviceFlow.js.map +1 -0
- package/dist/auth/provider.d.ts +32 -0
- package/dist/auth/provider.js +29 -0
- package/dist/auth/provider.js.map +1 -0
- package/dist/community/badges.d.ts +19 -0
- package/dist/community/badges.js +19 -0
- package/dist/community/badges.js.map +1 -0
- package/dist/community/events.d.ts +30 -0
- package/dist/community/events.js +31 -0
- package/dist/community/events.js.map +1 -0
- package/dist/community/identity.d.ts +28 -0
- package/dist/community/identity.js +2 -0
- package/dist/community/identity.js.map +1 -0
- package/dist/community/index.d.ts +7 -0
- package/dist/community/index.js +8 -0
- package/dist/community/index.js.map +1 -0
- package/dist/community/org.d.ts +46 -0
- package/dist/community/org.js +32 -0
- package/dist/community/org.js.map +1 -0
- package/dist/community/tiers.d.ts +8 -0
- package/dist/community/tiers.js +40 -0
- package/dist/community/tiers.js.map +1 -0
- package/dist/community/types.d.ts +26 -0
- package/dist/community/types.js +2 -0
- package/dist/community/types.js.map +1 -0
- package/dist/core/config.d.ts +22 -0
- package/dist/core/config.js +27 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/errors.d.ts +29 -0
- package/dist/core/errors.js +20 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/transport.d.ts +45 -0
- package/dist/core/transport.js +109 -0
- package/dist/core/transport.js.map +1 -0
- package/dist/diagram/core.d.ts +11 -0
- package/dist/diagram/core.js +12 -0
- package/dist/diagram/core.js.map +1 -0
- package/dist/diagram/extract.d.ts +17 -0
- package/dist/diagram/extract.js +213 -0
- package/dist/diagram/extract.js.map +1 -0
- package/dist/diagram/index.d.ts +2 -0
- package/dist/diagram/index.js +3 -0
- package/dist/diagram/index.js.map +1 -0
- package/dist/diagram/mermaid.d.ts +10 -0
- package/dist/diagram/mermaid.js +50 -0
- package/dist/diagram/mermaid.js.map +1 -0
- package/dist/diagram/prompt.d.ts +4 -0
- package/dist/diagram/prompt.js +16 -0
- package/dist/diagram/prompt.js.map +1 -0
- package/dist/diagram/types.d.ts +33 -0
- package/dist/diagram/types.js +2 -0
- package/dist/diagram/types.js.map +1 -0
- package/dist/diagram/validate.d.ts +13 -0
- package/dist/diagram/validate.js +48 -0
- package/dist/diagram/validate.js.map +1 -0
- package/dist/guide/compose.d.ts +10 -0
- package/dist/guide/compose.js +31 -0
- package/dist/guide/compose.js.map +1 -0
- package/dist/guide/core.d.ts +10 -0
- package/dist/guide/core.js +11 -0
- package/dist/guide/core.js.map +1 -0
- package/dist/guide/index.d.ts +2 -0
- package/dist/guide/index.js +3 -0
- package/dist/guide/index.js.map +1 -0
- package/dist/guide/prompt.d.ts +8 -0
- package/dist/guide/prompt.js +20 -0
- package/dist/guide/prompt.js.map +1 -0
- package/dist/guide/render.d.ts +9 -0
- package/dist/guide/render.js +180 -0
- package/dist/guide/render.js.map +1 -0
- package/dist/guide/types.d.ts +67 -0
- package/dist/guide/types.js +2 -0
- package/dist/guide/types.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/artifacts.generated.d.ts +19 -0
- package/dist/mcp/artifacts.generated.js +140 -0
- package/dist/mcp/artifacts.generated.js.map +1 -0
- package/dist/mcp/format.d.ts +10 -0
- package/dist/mcp/format.js +17 -0
- package/dist/mcp/format.js.map +1 -0
- package/dist/mcp/index.d.ts +12 -0
- package/dist/mcp/index.js +18 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/knowledge.generated.d.ts +11 -0
- package/dist/mcp/knowledge.generated.js +12 -0
- package/dist/mcp/knowledge.generated.js.map +1 -0
- package/dist/mcp/prompt-modules.generated.d.ts +12 -0
- package/dist/mcp/prompt-modules.generated.js +19 -0
- package/dist/mcp/prompt-modules.generated.js.map +1 -0
- package/dist/mcp/roles.generated.d.ts +15 -0
- package/dist/mcp/roles.generated.js +25 -0
- package/dist/mcp/roles.generated.js.map +1 -0
- package/dist/mcp/safety.d.ts +35 -0
- package/dist/mcp/safety.js +76 -0
- package/dist/mcp/safety.js.map +1 -0
- package/dist/mcp/scenarios.generated.d.ts +13 -0
- package/dist/mcp/scenarios.generated.js +16 -0
- package/dist/mcp/scenarios.generated.js.map +1 -0
- package/dist/mcp/search.d.ts +13 -0
- package/dist/mcp/search.js +33 -0
- package/dist/mcp/search.js.map +1 -0
- package/dist/mcp/skills.generated.d.ts +17 -0
- package/dist/mcp/skills.generated.js +40 -0
- package/dist/mcp/skills.generated.js.map +1 -0
- package/dist/mcp/toolset.d.ts +31 -0
- package/dist/mcp/toolset.js +54 -0
- package/dist/mcp/toolset.js.map +1 -0
- package/dist/mcp/types.d.ts +96 -0
- package/dist/mcp/types.js +9 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/mcp/workflows.generated.d.ts +17 -0
- package/dist/mcp/workflows.generated.js +12 -0
- package/dist/mcp/workflows.generated.js.map +1 -0
- package/dist/nocode/core.d.ts +12 -0
- package/dist/nocode/core.js +13 -0
- package/dist/nocode/core.js.map +1 -0
- package/dist/nocode/examples.d.ts +28 -0
- package/dist/nocode/examples.js +218 -0
- package/dist/nocode/examples.js.map +1 -0
- package/dist/nocode/index.d.ts +2 -0
- package/dist/nocode/index.js +3 -0
- package/dist/nocode/index.js.map +1 -0
- package/dist/nocode/mermaid.d.ts +9 -0
- package/dist/nocode/mermaid.js +33 -0
- package/dist/nocode/mermaid.js.map +1 -0
- package/dist/nocode/prompt.d.ts +8 -0
- package/dist/nocode/prompt.js +46 -0
- package/dist/nocode/prompt.js.map +1 -0
- package/dist/nocode/runtime.d.ts +28 -0
- package/dist/nocode/runtime.js +113 -0
- package/dist/nocode/runtime.js.map +1 -0
- package/dist/nocode/simpleOps.d.ts +16 -0
- package/dist/nocode/simpleOps.js +137 -0
- package/dist/nocode/simpleOps.js.map +1 -0
- package/dist/nocode/types.d.ts +72 -0
- package/dist/nocode/types.js +12 -0
- package/dist/nocode/types.js.map +1 -0
- package/dist/nocode/validate.d.ts +17 -0
- package/dist/nocode/validate.js +136 -0
- package/dist/nocode/validate.js.map +1 -0
- package/dist/params/codegen.d.ts +8 -0
- package/dist/params/codegen.js +12 -0
- package/dist/params/codegen.js.map +1 -0
- package/dist/params/convert.d.ts +7 -0
- package/dist/params/convert.js +123 -0
- package/dist/params/convert.js.map +1 -0
- package/dist/params/core.d.ts +11 -0
- package/dist/params/core.js +12 -0
- package/dist/params/core.js.map +1 -0
- package/dist/params/fieldTypes.d.ts +26 -0
- package/dist/params/fieldTypes.js +29 -0
- package/dist/params/fieldTypes.js.map +1 -0
- package/dist/params/index.d.ts +3 -0
- package/dist/params/index.js +4 -0
- package/dist/params/index.js.map +1 -0
- package/dist/params/prompt.d.ts +4 -0
- package/dist/params/prompt.js +16 -0
- package/dist/params/prompt.js.map +1 -0
- package/dist/params/render.d.ts +5 -0
- package/dist/params/render.js +25 -0
- package/dist/params/render.js.map +1 -0
- package/dist/params/types.d.ts +76 -0
- package/dist/params/types.js +16 -0
- package/dist/params/types.js.map +1 -0
- package/dist/params/validate.d.ts +5 -0
- package/dist/params/validate.js +104 -0
- package/dist/params/validate.js.map +1 -0
- package/dist/resources/client.d.ts +58 -0
- package/dist/resources/client.js +79 -0
- package/dist/resources/client.js.map +1 -0
- package/dist/resources/types.d.ts +72 -0
- package/dist/resources/types.js +9 -0
- package/dist/resources/types.js.map +1 -0
- package/dist/workflow/assets.d.ts +8 -0
- package/dist/workflow/assets.js +16 -0
- package/dist/workflow/assets.js.map +1 -0
- package/dist/workflow/commands.d.ts +10 -0
- package/dist/workflow/commands.js +21 -0
- package/dist/workflow/commands.js.map +1 -0
- package/dist/workflow/core.d.ts +15 -0
- package/dist/workflow/core.js +16 -0
- package/dist/workflow/core.js.map +1 -0
- package/dist/workflow/index.d.ts +2 -0
- package/dist/workflow/index.js +3 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/stack.d.ts +11 -0
- package/dist/workflow/stack.js +40 -0
- package/dist/workflow/stack.js.map +1 -0
- package/dist/workflow/templates.d.ts +17 -0
- package/dist/workflow/templates.js +223 -0
- package/dist/workflow/templates.js.map +1 -0
- package/dist/workflow/types.d.ts +27 -0
- package/dist/workflow/types.js +2 -0
- package/dist/workflow/types.js.map +1 -0
- package/package.json +77 -0
- package/schemas/artifacts.index.json +1211 -0
- package/schemas/knowledge.index.json +49 -0
- package/schemas/prompt-modules.index.json +105 -0
- package/schemas/roles.index.json +431 -0
- package/schemas/scenarios.index.json +15 -0
- package/schemas/skills.index.json +670 -0
- package/schemas/workflows.index.json +462 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XP events — the contributions the community recognizes, as a typed contract.
|
|
3
|
+
* This is a RECOGNITION layer: XP and badges celebrate contribution and inform a
|
|
4
|
+
* maintainer's tier decision; they do NOT automatically grant tiers or scopes
|
|
5
|
+
* (those stay human-provisioned + server-enforced, see tiers.ts). No backend
|
|
6
|
+
* ledger exists yet — `totalXp` lets tools score a known set of events offline.
|
|
7
|
+
*
|
|
8
|
+
* Referral note: `invite-accepted` recognizes a referral who actually joins. The web
|
|
9
|
+
* + CLI invite links carry a `ref` (see site/assets/invite.js, `cotrackpro community
|
|
10
|
+
* invite`), and the onboarding backend receives it at signup. When a server-side ledger
|
|
11
|
+
* exists, that backend should credit the REFERRER's `invite-accepted` automatically;
|
|
12
|
+
* until then `cotrackpro community log invite-accepted` is the manual self-report path.
|
|
13
|
+
*/
|
|
14
|
+
export type XpEventId = "first-setup" | "complete-quickstart" | "publish-package" | "ship-project" | "contribute-template" | "merge-pr" | "answer-help" | "submit-showcase" | "invite-accepted";
|
|
15
|
+
export type XpCategory = "onboarding" | "build" | "contribute" | "community";
|
|
16
|
+
export interface XpEvent {
|
|
17
|
+
id: XpEventId;
|
|
18
|
+
label: string;
|
|
19
|
+
xp: number;
|
|
20
|
+
category: XpCategory;
|
|
21
|
+
/** Can it be earned more than once (and count each time)? */
|
|
22
|
+
repeatable: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const XP_EVENT_IDS: XpEventId[];
|
|
25
|
+
export declare const XP_EVENTS: Record<XpEventId, XpEvent>;
|
|
26
|
+
/**
|
|
27
|
+
* Score a known set of events. Non-repeatable events count at most once.
|
|
28
|
+
* Recognition only — never a scope/tier grant.
|
|
29
|
+
*/
|
|
30
|
+
export declare function totalXp(counts: Partial<Record<XpEventId, number>>): number;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const XP_EVENT_IDS = [
|
|
2
|
+
"first-setup", "complete-quickstart", "publish-package", "ship-project",
|
|
3
|
+
"contribute-template", "merge-pr", "answer-help", "submit-showcase", "invite-accepted",
|
|
4
|
+
];
|
|
5
|
+
export const XP_EVENTS = {
|
|
6
|
+
"first-setup": { id: "first-setup", label: "Completed setup", xp: 10, category: "onboarding", repeatable: false },
|
|
7
|
+
"complete-quickstart": { id: "complete-quickstart", label: "Finished the quickstart", xp: 15, category: "onboarding", repeatable: false },
|
|
8
|
+
"publish-package": { id: "publish-package", label: "Published a package", xp: 50, category: "build", repeatable: true },
|
|
9
|
+
"ship-project": { id: "ship-project", label: "Shipped a project from a blueprint", xp: 40, category: "build", repeatable: true },
|
|
10
|
+
"contribute-template": { id: "contribute-template", label: "Contributed a parameter set or blueprint", xp: 30, category: "contribute", repeatable: true },
|
|
11
|
+
"merge-pr": { id: "merge-pr", label: "Had a pull request merged", xp: 25, category: "contribute", repeatable: true },
|
|
12
|
+
"answer-help": { id: "answer-help", label: "Answered a community question", xp: 10, category: "community", repeatable: true },
|
|
13
|
+
"submit-showcase": { id: "submit-showcase", label: "Added a tool to the Showcase", xp: 20, category: "community", repeatable: true },
|
|
14
|
+
"invite-accepted": { id: "invite-accepted", label: "Invited someone who joined the community", xp: 25, category: "community", repeatable: true },
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Score a known set of events. Non-repeatable events count at most once.
|
|
18
|
+
* Recognition only — never a scope/tier grant.
|
|
19
|
+
*/
|
|
20
|
+
export function totalXp(counts) {
|
|
21
|
+
let xp = 0;
|
|
22
|
+
for (const id of XP_EVENT_IDS) {
|
|
23
|
+
const n = counts[id] ?? 0;
|
|
24
|
+
if (n <= 0)
|
|
25
|
+
continue;
|
|
26
|
+
const e = XP_EVENTS[id];
|
|
27
|
+
xp += e.xp * (e.repeatable ? n : 1);
|
|
28
|
+
}
|
|
29
|
+
return xp;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/community/events.ts"],"names":[],"mappings":"AAmCA,MAAM,CAAC,MAAM,YAAY,GAAgB;IACvC,aAAa,EAAE,qBAAqB,EAAE,iBAAi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AAE,KAAK,EAAE,8BAA8B,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE;IACpI,iBAAiB,EAAE,EAAE,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,0CAA0C,EAAE,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE;CACjJ,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,MAA0C;IAChE,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,CAAC;YAAE,SAAS;QACrB,MAAM,CAAC,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;QACxB,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Clerk-sourced identity a consumer resolves for a developer-community member.
|
|
3
|
+
* This is the SHAPE only — Clerk is the source of truth and the backend enforces;
|
|
4
|
+
* the CLI/SDK/Slack/antigravity all read this same shape from a verified JWT so
|
|
5
|
+
* authorization is consistent across surfaces. Import-free (types only).
|
|
6
|
+
*/
|
|
7
|
+
import type { TierId } from "./types.js";
|
|
8
|
+
export interface CommunityIdentity {
|
|
9
|
+
/** Clerk user id. */
|
|
10
|
+
userId: string;
|
|
11
|
+
/** Membership tier — Clerk `publicMetadata.tier` (Explorer → Maintainer). */
|
|
12
|
+
tier: TierId;
|
|
13
|
+
/** Clerk org role within the Developers org, e.g. "org:member" | "org:admin". */
|
|
14
|
+
orgRole?: string;
|
|
15
|
+
/** Cumulative org-permissions the JWT carries (`org:<feature>:<action>`). */
|
|
16
|
+
permissions?: string[];
|
|
17
|
+
/** Linked GitHub username — grants repo / proposer access (antigravity). */
|
|
18
|
+
githubUsername?: string;
|
|
19
|
+
/** Linked Slack user id — used to provision the tier's channels. */
|
|
20
|
+
slackUserId?: string;
|
|
21
|
+
}
|
|
22
|
+
/** The Clerk JWT claims every consumer authorizes against (template in the dashboard). */
|
|
23
|
+
export interface CommunityJwtClaims {
|
|
24
|
+
org_id: string;
|
|
25
|
+
org_role: string;
|
|
26
|
+
org_permissions: string[];
|
|
27
|
+
tier: TierId;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/community/identity.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Developer-community contract: the typed tier registry + cumulative helpers. */
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export * from "./tiers.js";
|
|
4
|
+
export * from "./events.js";
|
|
5
|
+
export * from "./badges.js";
|
|
6
|
+
export * from "./org.js";
|
|
7
|
+
export * from "./identity.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/community/index.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The developer-community membership contract: the Clerk Organization it maps to,
|
|
3
|
+
* the roles a person can SELECT when joining, and the org-permission ↔ scope
|
|
4
|
+
* identity. Declarative only — Clerk + the backend enforce; this is the shared
|
|
5
|
+
* shape the CLI, the portal, the Slack app, and the antigravity GitHub component
|
|
6
|
+
* all read so nobody re-invents the mapping. Import-free (types only).
|
|
7
|
+
*/
|
|
8
|
+
import type { TierId } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* The Clerk Organization that represents developer-community membership. Native
|
|
11
|
+
* Clerk org-permissions use the same `org:<feature>:<action>` shape as cotrackpro
|
|
12
|
+
* scopes, so the mapping is an IDENTITY — do not translate (see ORG_PERMISSIONS).
|
|
13
|
+
* New members join here at Explorer; their tier lives in `publicMetadata.tier`.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEVELOPERS_ORG: {
|
|
16
|
+
readonly slug: "cotrackpro-developers";
|
|
17
|
+
readonly label: "CoTrackPro Developers";
|
|
18
|
+
readonly defaultTier: TierId;
|
|
19
|
+
};
|
|
20
|
+
/** The org-permission strings that also ARE cotrackpro scopes (1:1, no translation). */
|
|
21
|
+
export declare const ORG_PERMISSIONS: readonly ["org:packages:read", "org:packages:publish", "org:registry:admin", "org:keys:manage"];
|
|
22
|
+
export type OrgPermission = (typeof ORG_PERMISSIONS)[number];
|
|
23
|
+
/** A selectable "developer community" role — what a person picks when they join. */
|
|
24
|
+
export interface CommunityRole {
|
|
25
|
+
id: string;
|
|
26
|
+
label: string;
|
|
27
|
+
blurb: string;
|
|
28
|
+
/** Everyone starts at Explorer; tier progression is human-reviewed (see tiers.ts). */
|
|
29
|
+
startTier: TierId;
|
|
30
|
+
}
|
|
31
|
+
export declare const COMMUNITY_ROLES: CommunityRole[];
|
|
32
|
+
export declare const COMMUNITY_ROLE_IDS: string[];
|
|
33
|
+
/** The three converging ways to select the developer-community role. */
|
|
34
|
+
export declare const JOIN_ENTRY_POINTS: readonly [{
|
|
35
|
+
readonly id: "web";
|
|
36
|
+
readonly label: "Sign up on the web";
|
|
37
|
+
readonly detail: "developer.cotrackpro.com → sign in → choose “Developer community”. Self-serve; starts you at Explorer.";
|
|
38
|
+
}, {
|
|
39
|
+
readonly id: "github";
|
|
40
|
+
readonly label: "Apply on GitHub";
|
|
41
|
+
readonly detail: "Open the developer-community application issue; a maintainer provisions your Clerk identity + tier.";
|
|
42
|
+
}, {
|
|
43
|
+
readonly id: "cli";
|
|
44
|
+
readonly label: "From the CLI";
|
|
45
|
+
readonly detail: "`cotrackpro community join` explains the role, tiers, and the link steps.";
|
|
46
|
+
}];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Clerk Organization that represents developer-community membership. Native
|
|
3
|
+
* Clerk org-permissions use the same `org:<feature>:<action>` shape as cotrackpro
|
|
4
|
+
* scopes, so the mapping is an IDENTITY — do not translate (see ORG_PERMISSIONS).
|
|
5
|
+
* New members join here at Explorer; their tier lives in `publicMetadata.tier`.
|
|
6
|
+
*/
|
|
7
|
+
export const DEVELOPERS_ORG = {
|
|
8
|
+
slug: "cotrackpro-developers",
|
|
9
|
+
label: "CoTrackPro Developers",
|
|
10
|
+
defaultTier: "explorer",
|
|
11
|
+
};
|
|
12
|
+
/** The org-permission strings that also ARE cotrackpro scopes (1:1, no translation). */
|
|
13
|
+
export const ORG_PERMISSIONS = [
|
|
14
|
+
"org:packages:read",
|
|
15
|
+
"org:packages:publish",
|
|
16
|
+
"org:registry:admin",
|
|
17
|
+
"org:keys:manage",
|
|
18
|
+
];
|
|
19
|
+
export const COMMUNITY_ROLES = [
|
|
20
|
+
{ id: "developer", label: "Developer", blurb: "Build tools and contribute code on the CLI and SDK.", startTier: "explorer" },
|
|
21
|
+
{ id: "solution-builder", label: "Solution builder", blurb: "Assemble solutions for organizations or clients.", startTier: "explorer" },
|
|
22
|
+
{ id: "researcher", label: "Researcher / faculty", blurb: "Study or teach with the catalog and the platform tools.", startTier: "explorer" },
|
|
23
|
+
{ id: "student", label: "Student / intern", blurb: "Learn by building real, child-centered tools.", startTier: "explorer" },
|
|
24
|
+
];
|
|
25
|
+
export const COMMUNITY_ROLE_IDS = COMMUNITY_ROLES.map((r) => r.id);
|
|
26
|
+
/** The three converging ways to select the developer-community role. */
|
|
27
|
+
export const JOIN_ENTRY_POINTS = [
|
|
28
|
+
{ id: "web", label: "Sign up on the web", detail: "developer.cotrackpro.com → sign in → choose “Developer community”. Self-serve; starts you at Explorer." },
|
|
29
|
+
{ id: "github", label: "Apply on GitHub", detail: "Open the developer-community application issue; a maintainer provisions your Clerk identity + tier." },
|
|
30
|
+
{ id: "cli", label: "From the CLI", detail: "`cotrackpro community join` explains the role, tiers, and the link steps." },
|
|
31
|
+
];
|
|
32
|
+
//# sourceMappingURL=org.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"org.js","sourceRoot":"","sources":["../../src/community/org.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,IAAI,EAAE,uBAAuB;IAC7B,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EAAE,UAAoB;CACzB,CAAC;AAEX,wFAAwF;AACxF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,mBAAmB;IACnB,sBAAsB;IACtB,oBAAoB;IACpB,iBAAiB;CACT,CAAC;AAYX,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,qDAAqD,EAAE,SAAS,EAAE,UAAU,EAAE;IAC5H,EAAE,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,kDAAkD,EAAE,SAAS,EAAE,UAAU,EAAE;IACvI,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,yDAAyD,EAAE,SAAS,EAAE,UAAU,EAAE;IAC5I,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,+CAA+C,EAAE,SAAS,EAAE,UAAU,EAAE;CAC5H,CAAC;AACF,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAEnE,wEAAwE;AACxE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,EAAE,wGAAwG,EAAE;IAC5J,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,qGAAqG,EAAE;IACzJ,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,2EAA2E,EAAE;CACjH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The developer-community tiers (authored contract — the source of truth). */
|
|
2
|
+
import type { Tier, TierId } from "./types.js";
|
|
3
|
+
export declare const TIER_IDS: TierId[];
|
|
4
|
+
export declare const TIERS: Record<TierId, Tier>;
|
|
5
|
+
/** All scopes available AT OR BELOW a tier (cumulative, deduped, declarative). */
|
|
6
|
+
export declare function scopesForTier(id: TierId): string[];
|
|
7
|
+
/** All Slack channels a member of this tier can see (cumulative). */
|
|
8
|
+
export declare function channelsForTier(id: TierId): string[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const TIER_IDS = ["explorer", "builder", "scholar", "maintainer"];
|
|
2
|
+
export const TIERS = {
|
|
3
|
+
explorer: {
|
|
4
|
+
id: "explorer", label: "Explorer", order: 1, applyable: true,
|
|
5
|
+
slackAdds: ["#general", "#help", "#announcements"],
|
|
6
|
+
scopes: [],
|
|
7
|
+
capability: "Browse the public catalog",
|
|
8
|
+
},
|
|
9
|
+
builder: {
|
|
10
|
+
id: "builder", label: "Builder", order: 2, applyable: true,
|
|
11
|
+
slackAdds: ["#builders", "#show-and-tell"],
|
|
12
|
+
scopes: ["org:packages:read"],
|
|
13
|
+
capability: "Build with the SDK against a sandbox org",
|
|
14
|
+
},
|
|
15
|
+
scholar: {
|
|
16
|
+
id: "scholar", label: "Scholar", order: 3, applyable: false,
|
|
17
|
+
slackAdds: ["#rfcs", "#scholars"],
|
|
18
|
+
scopes: [],
|
|
19
|
+
capability: "Propose changes via PRs; read sensitive summaries",
|
|
20
|
+
},
|
|
21
|
+
maintainer: {
|
|
22
|
+
id: "maintainer", label: "Maintainer", order: 4, applyable: false,
|
|
23
|
+
slackAdds: ["#triage", "private maintainer channels"],
|
|
24
|
+
scopes: ["org:packages:publish", "org:registry:admin"],
|
|
25
|
+
capability: "Publish packages, review & merge, scoped registry admin",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const upTo = (id) => {
|
|
29
|
+
const order = TIERS[id].order;
|
|
30
|
+
return TIER_IDS.map((t) => TIERS[t]).filter((t) => t.order <= order);
|
|
31
|
+
};
|
|
32
|
+
/** All scopes available AT OR BELOW a tier (cumulative, deduped, declarative). */
|
|
33
|
+
export function scopesForTier(id) {
|
|
34
|
+
return [...new Set(upTo(id).flatMap((t) => t.scopes))];
|
|
35
|
+
}
|
|
36
|
+
/** All Slack channels a member of this tier can see (cumulative). */
|
|
37
|
+
export function channelsForTier(id) {
|
|
38
|
+
return upTo(id).flatMap((t) => t.slackAdds);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=tiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiers.js","sourceRoot":"","sources":["../../src/community/tiers.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,QAAQ,GAAa,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;AAEnF,MAAM,CAAC,MAAM,KAAK,GAAyB;IACzC,QAAQ,EAAE;QACR,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI;QAC5D,SAAS,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,gBAAgB,CAAC;QAClD,MAAM,EAAE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AAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Developer-community tier contract. The single typed source of truth for the
|
|
3
|
+
* membership tiers shown on the Join page, exposed by `cotrackpro community`,
|
|
4
|
+
* and provisioned against by the backend + the `cotrackpro-slack` app.
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: tiers DECLARE which RBAC scopes and Slack channels they map to —
|
|
7
|
+
* they do not grant anything. Enforcement is server-side (Clerk identity + the
|
|
8
|
+
* gated-access broker); the CLI/SDK never grant scopes from a tier. Tiers also
|
|
9
|
+
* never unlock confidential family-case data — that is a separate professional
|
|
10
|
+
* role axis. Import-free so the portal and the Slack app can share it.
|
|
11
|
+
*/
|
|
12
|
+
export type TierId = "explorer" | "builder" | "scholar" | "maintainer";
|
|
13
|
+
export interface Tier {
|
|
14
|
+
id: TierId;
|
|
15
|
+
label: string;
|
|
16
|
+
/** 1..4 — Explorer is lowest, Maintainer highest. */
|
|
17
|
+
order: number;
|
|
18
|
+
/** Can a new member apply directly at this tier? (Scholar/Maintainer are earned.) */
|
|
19
|
+
applyable: boolean;
|
|
20
|
+
/** Slack channels ADDED at this tier, on top of lower tiers. */
|
|
21
|
+
slackAdds: string[];
|
|
22
|
+
/** RBAC scopes this tier maps to — declarative, enforced server-side. */
|
|
23
|
+
scopes: string[];
|
|
24
|
+
/** One line: the building capability this tier unlocks. */
|
|
25
|
+
capability: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/community/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic config resolution.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the precedence in the CLI's `src/lib/config.ts`
|
|
5
|
+
* (flag → env → project → user → default) but takes its inputs as plain layers
|
|
6
|
+
* so it is not tied to `process.env` or the filesystem — a browser app, an edge
|
|
7
|
+
* function, or an Antigravity agent can supply layers however it likes.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_BASE_URL = "https://api.cotrackpro.com";
|
|
10
|
+
export interface ConfigLayer {
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
org?: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface ResolvedSdkConfig {
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
org: string | null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolve config from highest-priority layer first. Earlier layers win.
|
|
20
|
+
* Typical order: [flags, env, projectConfig, userConfig].
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveSdkConfig(...layers: Array<ConfigLayer | undefined>): ResolvedSdkConfig;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic config resolution.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the precedence in the CLI's `src/lib/config.ts`
|
|
5
|
+
* (flag → env → project → user → default) but takes its inputs as plain layers
|
|
6
|
+
* so it is not tied to `process.env` or the filesystem — a browser app, an edge
|
|
7
|
+
* function, or an Antigravity agent can supply layers however it likes.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_BASE_URL = "https://api.cotrackpro.com";
|
|
10
|
+
/**
|
|
11
|
+
* Resolve config from highest-priority layer first. Earlier layers win.
|
|
12
|
+
* Typical order: [flags, env, projectConfig, userConfig].
|
|
13
|
+
*/
|
|
14
|
+
export function resolveSdkConfig(...layers) {
|
|
15
|
+
let baseUrl;
|
|
16
|
+
let org;
|
|
17
|
+
for (const layer of layers) {
|
|
18
|
+
if (!layer)
|
|
19
|
+
continue;
|
|
20
|
+
if (baseUrl === undefined && layer.baseUrl)
|
|
21
|
+
baseUrl = layer.baseUrl;
|
|
22
|
+
if (org === undefined && layer.org !== undefined)
|
|
23
|
+
org = layer.org;
|
|
24
|
+
}
|
|
25
|
+
return { baseUrl: baseUrl ?? DEFAULT_BASE_URL, org: org ?? null };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AAY7D;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAG,MAAsC;IACxE,IAAI,OAA2B,CAAC;IAChC,IAAI,GAA8B,CAAC;IACnC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,KAAK;YAAE,SAAS;QACrB,IAAI,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO;YAAE,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QACpE,IAAI,GAAG,KAAK,SAAS,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS;YAAE,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;IACpE,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,GAAG,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Framework-agnostic error type for every CoTrackPro API interaction.
|
|
3
|
+
*
|
|
4
|
+
* This is the shape the CLI's `CliError` wraps (see `src/lib/errors.ts`), but it
|
|
5
|
+
* carries no Node/CLI assumptions so it works unchanged in browsers, edge
|
|
6
|
+
* runtimes, and agent/IDE hosts (e.g. Antigravity).
|
|
7
|
+
*/
|
|
8
|
+
export interface CotrackproErrorInit {
|
|
9
|
+
/** Stable machine code, e.g. "unauthenticated", "forbidden", "network", "http_500". */
|
|
10
|
+
code: string;
|
|
11
|
+
message: string;
|
|
12
|
+
/** HTTP status when the error originated from a response. */
|
|
13
|
+
status?: number;
|
|
14
|
+
/** Server request id (x-request-id) for support/debugging. */
|
|
15
|
+
requestId?: string;
|
|
16
|
+
/** RBAC permission the caller was missing, when code is "forbidden". */
|
|
17
|
+
requiredPermission?: string;
|
|
18
|
+
/** Org slug the request was scoped to, when relevant. */
|
|
19
|
+
org?: string | null;
|
|
20
|
+
}
|
|
21
|
+
export declare class CotrackproError extends Error {
|
|
22
|
+
readonly code: string;
|
|
23
|
+
readonly status?: number;
|
|
24
|
+
readonly requestId?: string;
|
|
25
|
+
readonly requiredPermission?: string;
|
|
26
|
+
readonly org: string | null;
|
|
27
|
+
constructor(init: CotrackproErrorInit);
|
|
28
|
+
}
|
|
29
|
+
export declare function isCotrackproError(e: unknown): e is CotrackproError;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class CotrackproError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
status;
|
|
4
|
+
requestId;
|
|
5
|
+
requiredPermission;
|
|
6
|
+
org;
|
|
7
|
+
constructor(init) {
|
|
8
|
+
super(init.message);
|
|
9
|
+
this.name = "CotrackproError";
|
|
10
|
+
this.code = init.code;
|
|
11
|
+
this.status = init.status;
|
|
12
|
+
this.requestId = init.requestId;
|
|
13
|
+
this.requiredPermission = init.requiredPermission;
|
|
14
|
+
this.org = init.org ?? null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function isCotrackproError(e) {
|
|
18
|
+
return e instanceof CotrackproError;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAqBA,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAS;IACb,MAAM,CAAU;IAChB,SAAS,CAAU;IACnB,kBAAkB,CAAU;IAC5B,GAAG,CAAgB;IAE5B,YAAY,IAAyB;QACnC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC;QAClD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,CAAU;IAC1C,OAAO,CAAC,YAAY,eAAe,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** A `fetch`-compatible function. Injectable so the SDK runs anywhere. */
|
|
2
|
+
export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
3
|
+
export interface TransportConfig {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
/** API prefix appended after baseUrl. Defaults to the CLI API surface. */
|
|
6
|
+
basePath?: string;
|
|
7
|
+
/** Override the fetch implementation (defaults to global `fetch`). */
|
|
8
|
+
fetch?: FetchLike;
|
|
9
|
+
/** Max retries for idempotent requests on network errors / 5xx. Default 2. */
|
|
10
|
+
retries?: number;
|
|
11
|
+
/** Base backoff in ms (doubled each attempt). Default 200. */
|
|
12
|
+
retryBaseMs?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Per-request timeout in ms. A hung connection would otherwise hang the CLI
|
|
15
|
+
* forever (Node's fetch has no default timeout). `0` disables it. Default 30000.
|
|
16
|
+
*/
|
|
17
|
+
timeoutMs?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface RequestParams {
|
|
20
|
+
path: string;
|
|
21
|
+
method?: string;
|
|
22
|
+
body?: unknown;
|
|
23
|
+
/** Org slug for the `x-cotrackpro-org` header. Falsy = header omitted. */
|
|
24
|
+
org?: string | null;
|
|
25
|
+
/** Bearer token. Falsy = no Authorization header. */
|
|
26
|
+
token?: string | null;
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Low-level HTTP transport. Generalizes the CLI's hand-rolled `api()`
|
|
31
|
+
* (`src/lib/http.ts`): `/cli/v1` base path, `x-cotrackpro-org` scoping,
|
|
32
|
+
* `x-request-id` capture, `{ data }` unwrapping, and a uniform error model —
|
|
33
|
+
* now with retry-with-backoff for idempotent requests.
|
|
34
|
+
*/
|
|
35
|
+
export declare class Transport {
|
|
36
|
+
private readonly baseUrl;
|
|
37
|
+
private readonly basePath;
|
|
38
|
+
private readonly fetchImpl;
|
|
39
|
+
private readonly retries;
|
|
40
|
+
private readonly retryBaseMs;
|
|
41
|
+
private readonly timeoutMs;
|
|
42
|
+
constructor(cfg: TransportConfig);
|
|
43
|
+
request<T>(p: RequestParams): Promise<T>;
|
|
44
|
+
private backoff;
|
|
45
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { CotrackproError } from "./errors.js";
|
|
2
|
+
const DEFAULT_BASE_PATH = "/cli/v1";
|
|
3
|
+
/**
|
|
4
|
+
* Low-level HTTP transport. Generalizes the CLI's hand-rolled `api()`
|
|
5
|
+
* (`src/lib/http.ts`): `/cli/v1` base path, `x-cotrackpro-org` scoping,
|
|
6
|
+
* `x-request-id` capture, `{ data }` unwrapping, and a uniform error model —
|
|
7
|
+
* now with retry-with-backoff for idempotent requests.
|
|
8
|
+
*/
|
|
9
|
+
export class Transport {
|
|
10
|
+
baseUrl;
|
|
11
|
+
basePath;
|
|
12
|
+
fetchImpl;
|
|
13
|
+
retries;
|
|
14
|
+
retryBaseMs;
|
|
15
|
+
timeoutMs;
|
|
16
|
+
constructor(cfg) {
|
|
17
|
+
this.baseUrl = cfg.baseUrl.replace(/\/+$/, "");
|
|
18
|
+
this.basePath = cfg.basePath ?? DEFAULT_BASE_PATH;
|
|
19
|
+
const f = cfg.fetch ?? globalThis.fetch;
|
|
20
|
+
if (!f) {
|
|
21
|
+
throw new CotrackproError({
|
|
22
|
+
code: "config_error",
|
|
23
|
+
message: "No fetch implementation available; pass `fetch` to createClient().",
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
this.fetchImpl = f;
|
|
27
|
+
this.retries = cfg.retries ?? 2;
|
|
28
|
+
this.retryBaseMs = cfg.retryBaseMs ?? 200;
|
|
29
|
+
this.timeoutMs = cfg.timeoutMs ?? 30000;
|
|
30
|
+
}
|
|
31
|
+
async request(p) {
|
|
32
|
+
const headers = { "content-type": "application/json", ...p.headers };
|
|
33
|
+
if (p.token)
|
|
34
|
+
headers.authorization = `Bearer ${p.token}`;
|
|
35
|
+
if (p.org)
|
|
36
|
+
headers["x-cotrackpro-org"] = p.org;
|
|
37
|
+
const url = `${this.baseUrl}${this.basePath}${p.path}`;
|
|
38
|
+
const method = p.method ?? "GET";
|
|
39
|
+
const bodyInit = p.body !== undefined ? JSON.stringify(p.body) : undefined;
|
|
40
|
+
// Only retry requests with no side effects to avoid duplicate writes.
|
|
41
|
+
const idempotent = method === "GET" || method === "HEAD";
|
|
42
|
+
let attempt = 0;
|
|
43
|
+
for (;;) {
|
|
44
|
+
// A fresh controller per attempt: an aborted signal can't be reused, and a
|
|
45
|
+
// retry needs its own timeout window.
|
|
46
|
+
const controller = new AbortController();
|
|
47
|
+
const timer = this.timeoutMs > 0 ? setTimeout(() => controller.abort(), this.timeoutMs) : undefined;
|
|
48
|
+
const canRetry = idempotent && attempt < this.retries;
|
|
49
|
+
let res;
|
|
50
|
+
let text;
|
|
51
|
+
try {
|
|
52
|
+
res = await this.fetchImpl(url, { method, headers, body: bodyInit, signal: controller.signal });
|
|
53
|
+
// Read the body inside the same timeout window — a stalled body stream is
|
|
54
|
+
// just as much a hang as a stalled connection.
|
|
55
|
+
text = await res.text();
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
const timedOut = controller.signal.aborted;
|
|
59
|
+
if (timer)
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
if (canRetry) {
|
|
62
|
+
await delay(this.backoff(attempt));
|
|
63
|
+
attempt++;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
throw new CotrackproError({
|
|
67
|
+
code: "network",
|
|
68
|
+
message: timedOut ? `Request timed out after ${this.timeoutMs}ms` : `Network error: ${e.message}`,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (timer)
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
const requestId = res.headers.get("x-request-id") ?? undefined;
|
|
74
|
+
const json = text ? safeJson(text) : undefined;
|
|
75
|
+
if (!res.ok) {
|
|
76
|
+
if (idempotent && res.status >= 500 && attempt < this.retries) {
|
|
77
|
+
await delay(this.backoff(attempt));
|
|
78
|
+
attempt++;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const err = json?.error ?? {};
|
|
82
|
+
throw new CotrackproError({
|
|
83
|
+
code: err.code ?? `http_${res.status}`,
|
|
84
|
+
message: err.message ?? `Request failed (${res.status})`,
|
|
85
|
+
status: res.status,
|
|
86
|
+
requestId,
|
|
87
|
+
requiredPermission: err.requiredPermission,
|
|
88
|
+
org: err.org ?? null,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return (json?.data ?? json);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
backoff(attempt) {
|
|
95
|
+
return this.retryBaseMs * 2 ** attempt;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function safeJson(s) {
|
|
99
|
+
try {
|
|
100
|
+
return JSON.parse(s);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function delay(ms) {
|
|
107
|
+
return new Promise((r) => setTimeout(r, ms));
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/core/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAiC9C,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,OAAO,SAAS;IACH,OAAO,CAAS;IAChB,QAAQ,CAAS;IACjB,SAAS,CAAY;IACrB,OAAO,CAAS;IAChB,WAAW,CAAS;IACpB,SAAS,CAAS;IAEnC,YAAY,GAAoB;QAC9B,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,QAAQ,IAAI,iBAAiB,CAAC;QAClD,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,IAAK,UAAU,CAAC,KAA+B,CAAC;QACnE,IAAI,CAAC,CAAC,EAAE,CAAC;YACP,MAAM,IAAI,eAAe,CAAC;gBACxB,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE,oEAAoE;aAC9E,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,KAAK,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,OAAO,CAAI,CAAgB;QAC/B,MAAM,OAAO,GAA2B,EAAE,cAAc,EAAE,kBAAkB,EAAE,GAAG,CAAC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MAAM,IAAI,eAAe,CAAC;oBACxB,IAAI,EAAG,GAAG,CAAC,IAA2B,IAAI,QAAQ,GAAG,CAAC,MAAM,EAAE;oBAC9D,OAAO,EAAG,GAAG,CAAC,OAA8B,IAAI,mBAAmB,GAAG,CAAC,MAAM,GAAG;oBAChF,MAAM,EAAE,GAAG,CAAC,MAAM;oBAClB,SAAS;oBACT,kBAAkB,EAAE,GAAG,CAAC,kBAAwC;oBAChE,GAAG,EAAG,GAAG,CAAC,GAAiC,IAAI,IAAI;iBACpD,CAAC,CAAC;YACL,CAAC;YAED,OAAO,CAAE,IAAiC,EAAE,IAAI,IAAK,IAAU,CAAM,CAAC;QACxE,CAAC;IACH,CAAC;IAEO,OAAO,CAAC,OAAe;QAC7B,OAAO,IAAI,CAAC,WAAW,GAAG,CAAC,IAAI,OAAO,CAAC;IACzC,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,CAAS;IACzB,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe barrel for the diagram engine. Import-free by construction so
|
|
3
|
+
* the compiled output loads directly in the portal builder — the CLI and the
|
|
4
|
+
* portal share the exact extract/render/validate logic. Keep it that way (an
|
|
5
|
+
* SDK test enforces no external imports).
|
|
6
|
+
*/
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
export * from "./extract.js";
|
|
9
|
+
export * from "./mermaid.js";
|
|
10
|
+
export * from "./validate.js";
|
|
11
|
+
export * from "./prompt.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe barrel for the diagram engine. Import-free by construction so
|
|
3
|
+
* the compiled output loads directly in the portal builder — the CLI and the
|
|
4
|
+
* portal share the exact extract/render/validate logic. Keep it that way (an
|
|
5
|
+
* SDK test enforces no external imports).
|
|
6
|
+
*/
|
|
7
|
+
export * from "./types.js";
|
|
8
|
+
export * from "./extract.js";
|
|
9
|
+
export * from "./mermaid.js";
|
|
10
|
+
export * from "./validate.js";
|
|
11
|
+
export * from "./prompt.js";
|
|
12
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/diagram/core.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic logic extraction: turn a document (or a parameter set) into a
|
|
3
|
+
* flowchart. No AI, no deps — heuristic but predictable, so the same input
|
|
4
|
+
* always yields the same diagram. Free-prose refinement is a manual edit in the
|
|
5
|
+
* builder (or an optional AI-assist pass documented separately).
|
|
6
|
+
*/
|
|
7
|
+
import type { Diagram, Direction } from "./types.js";
|
|
8
|
+
import type { ParamSet } from "../params/types.js";
|
|
9
|
+
/** Extract a flowchart from free-ish text (steps, if/then/else, and decision branches). */
|
|
10
|
+
export declare function extractFromText(text: string, opts?: {
|
|
11
|
+
direction?: Direction;
|
|
12
|
+
title?: string;
|
|
13
|
+
}): Diagram;
|
|
14
|
+
/** Extract a data-collection flowchart from a parameter set (the builder logic). */
|
|
15
|
+
export declare function extractFromParamSet(set: ParamSet, opts?: {
|
|
16
|
+
direction?: Direction;
|
|
17
|
+
}): Diagram;
|