@myapihq/sdk 1.2.6 → 1.2.8
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/dist/config.d.ts +1 -0
- package/dist/config.js +2 -1
- package/dist/container.d.ts +54 -0
- package/dist/container.js +46 -0
- package/dist/hq.d.ts +12 -0
- package/dist/hq.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/services.js +19 -1
- package/package.json +1 -1
- package/src/config.ts +1 -0
- package/src/container.ts +106 -0
- package/src/hq.ts +24 -0
- package/src/index.ts +1 -0
- package/src/services.ts +19 -1
package/dist/config.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const DOMAIN_BASE: string;
|
|
|
3
3
|
export declare const FUNNEL_BASE: string;
|
|
4
4
|
export declare const FUNCTION_BASE: string;
|
|
5
5
|
export declare const PAYMENTS_BASE: string;
|
|
6
|
+
export declare const CONTAINER_BASE: string;
|
|
6
7
|
export declare const IMAGE_BASE: string;
|
|
7
8
|
export declare const WEBHOOK_BASE: string;
|
|
8
9
|
export declare const WORKFLOW_BASE: string;
|
package/dist/config.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// local dev — `source scripts/local-env.sh` still points everything at
|
|
9
9
|
// localhost:8080 regardless of the prod default.
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.CRM_BASE = exports.DATABASE_BASE = exports.LLM_BASE = exports.AUDIENCE_BASE = exports.COMPANY_BASE = exports.PEOPLE_BASE = exports.PIXEL_BASE = exports.URL_BASE = exports.STORAGE_BASE = exports.EMAIL_BASE = exports.WORKFLOW_BASE = exports.WEBHOOK_BASE = exports.IMAGE_BASE = exports.PAYMENTS_BASE = exports.FUNCTION_BASE = exports.FUNNEL_BASE = exports.DOMAIN_BASE = exports.HQ_BASE = void 0;
|
|
11
|
+
exports.CRM_BASE = exports.DATABASE_BASE = exports.LLM_BASE = exports.AUDIENCE_BASE = exports.COMPANY_BASE = exports.PEOPLE_BASE = exports.PIXEL_BASE = exports.URL_BASE = exports.STORAGE_BASE = exports.EMAIL_BASE = exports.WORKFLOW_BASE = exports.WEBHOOK_BASE = exports.IMAGE_BASE = exports.CONTAINER_BASE = exports.PAYMENTS_BASE = exports.FUNCTION_BASE = exports.FUNNEL_BASE = exports.DOMAIN_BASE = exports.HQ_BASE = void 0;
|
|
12
12
|
const GATEWAY = 'https://api.myapihq.com';
|
|
13
13
|
exports.HQ_BASE = process.env.MYAPI_HQ_URL ?? process.env.MYAPI_API_BASE ?? GATEWAY;
|
|
14
14
|
exports.DOMAIN_BASE = process.env.MYAPI_DOMAIN_URL ?? 'https://api.mydomainapi.com';
|
|
@@ -17,6 +17,7 @@ exports.FUNNEL_BASE = process.env.MYAPI_FUNNEL_URL ?? 'https://api.myfunnelapi.c
|
|
|
17
17
|
// (mirrors the LLM/DATABASE/CRM pattern below).
|
|
18
18
|
exports.FUNCTION_BASE = process.env.MYAPI_FUNCTION_URL ?? GATEWAY;
|
|
19
19
|
exports.PAYMENTS_BASE = process.env.MYAPI_PAYMENTS_URL ?? GATEWAY;
|
|
20
|
+
exports.CONTAINER_BASE = process.env.MYAPI_CONTAINER_URL ?? GATEWAY;
|
|
20
21
|
exports.IMAGE_BASE = process.env.MYAPI_IMAGE_URL ?? 'https://api.myimageapi.com';
|
|
21
22
|
exports.WEBHOOK_BASE = process.env.MYAPI_WEBHOOK_URL ?? 'https://api.mywebhookapi.com';
|
|
22
23
|
exports.WORKFLOW_BASE = process.env.MYAPI_WORKFLOW_URL ?? 'https://api.myworkflowapi.com';
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Exposes } from './exposes';
|
|
2
|
+
export declare const EXPOSES: Exposes;
|
|
3
|
+
export type ContainerType = 'service' | 'worker' | 'job';
|
|
4
|
+
export interface Container {
|
|
5
|
+
id: string;
|
|
6
|
+
org_id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
type: ContainerType;
|
|
9
|
+
cron_schedule?: string;
|
|
10
|
+
env: Record<string, unknown>;
|
|
11
|
+
cpu: string;
|
|
12
|
+
memory: string;
|
|
13
|
+
min_instances: number;
|
|
14
|
+
max_instances: number;
|
|
15
|
+
port: number;
|
|
16
|
+
url?: string;
|
|
17
|
+
status: string;
|
|
18
|
+
created_at: string;
|
|
19
|
+
updated_at: string;
|
|
20
|
+
}
|
|
21
|
+
export interface CreatePayload {
|
|
22
|
+
name: string;
|
|
23
|
+
type?: ContainerType;
|
|
24
|
+
cron_schedule?: string;
|
|
25
|
+
env?: Record<string, unknown>;
|
|
26
|
+
cpu?: string;
|
|
27
|
+
memory?: string;
|
|
28
|
+
min_instances?: number;
|
|
29
|
+
max_instances?: number;
|
|
30
|
+
port?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface CreateResponse {
|
|
33
|
+
container: Container;
|
|
34
|
+
scoped_api_key: string;
|
|
35
|
+
scoped_api_key_id: string;
|
|
36
|
+
}
|
|
37
|
+
export interface DeployResponse {
|
|
38
|
+
container_id: string;
|
|
39
|
+
revision_id: string;
|
|
40
|
+
url: string;
|
|
41
|
+
status: string;
|
|
42
|
+
scoped_api_key: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function createContainer(apiKey: string, orgId: string, payload: CreatePayload): Promise<CreateResponse>;
|
|
45
|
+
export declare function listContainers(apiKey: string, orgId: string): Promise<Container[]>;
|
|
46
|
+
export declare function getContainer(apiKey: string, orgId: string, containerId: string): Promise<Container>;
|
|
47
|
+
export declare function deleteContainer(apiKey: string, orgId: string, containerId: string): Promise<void>;
|
|
48
|
+
export declare function deployContainer(apiKey: string, orgId: string, containerId: string, image: string): Promise<DeployResponse>;
|
|
49
|
+
export interface LogEntry {
|
|
50
|
+
timestamp: string;
|
|
51
|
+
severity: string;
|
|
52
|
+
text: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function getContainerLogs(apiKey: string, orgId: string, containerId: string, tail?: number): Promise<LogEntry[]>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EXPOSES = void 0;
|
|
4
|
+
exports.createContainer = createContainer;
|
|
5
|
+
exports.listContainers = listContainers;
|
|
6
|
+
exports.getContainer = getContainer;
|
|
7
|
+
exports.deleteContainer = deleteContainer;
|
|
8
|
+
exports.deployContainer = deployContainer;
|
|
9
|
+
exports.getContainerLogs = getContainerLogs;
|
|
10
|
+
const client_1 = require("./client");
|
|
11
|
+
const config_1 = require("./config");
|
|
12
|
+
// Backend: my-container-api per myapi-hq/internal/routes/container/. Phase 1
|
|
13
|
+
// is metadata + scoped API key issuance; the Cloud Run build/deploy pipeline
|
|
14
|
+
// is Phase 2 — `deployContainer` returns RUNTIME_UNAVAILABLE until it lands.
|
|
15
|
+
exports.EXPOSES = [
|
|
16
|
+
'POST /container/orgs/{org_id}/containers',
|
|
17
|
+
'GET /container/orgs/{org_id}/containers',
|
|
18
|
+
'GET /container/orgs/{org_id}/containers/{id}',
|
|
19
|
+
'DELETE /container/orgs/{org_id}/containers/{id}',
|
|
20
|
+
'POST /container/orgs/{org_id}/containers/{id}/deploy',
|
|
21
|
+
'GET /container/orgs/{org_id}/containers/{id}/logs',
|
|
22
|
+
];
|
|
23
|
+
async function createContainer(apiKey, orgId, payload) {
|
|
24
|
+
return (0, client_1.request)('POST', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers`, apiKey, payload);
|
|
25
|
+
}
|
|
26
|
+
async function listContainers(apiKey, orgId) {
|
|
27
|
+
return (0, client_1.request)('GET', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers`, apiKey);
|
|
28
|
+
}
|
|
29
|
+
async function getContainer(apiKey, orgId, containerId) {
|
|
30
|
+
return (0, client_1.request)('GET', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}`, apiKey);
|
|
31
|
+
}
|
|
32
|
+
async function deleteContainer(apiKey, orgId, containerId) {
|
|
33
|
+
return (0, client_1.request)('DELETE', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}`, apiKey);
|
|
34
|
+
}
|
|
35
|
+
// deployContainer ships a revision from a pre-built image ref to Cloud Run
|
|
36
|
+
// (source builds land in a later backend slice). Rotates the scoped key.
|
|
37
|
+
async function deployContainer(apiKey, orgId, containerId, image) {
|
|
38
|
+
return (0, client_1.request)('POST', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}/deploy`, apiKey, { image });
|
|
39
|
+
}
|
|
40
|
+
// getContainerLogs returns recent runtime log entries, newest first.
|
|
41
|
+
// `tail` caps the count (default 100, max 1000 server-side). An
|
|
42
|
+
// undeployed container returns an empty array.
|
|
43
|
+
async function getContainerLogs(apiKey, orgId, containerId, tail) {
|
|
44
|
+
const query = tail ? `?tail=${encodeURIComponent(String(tail))}` : '';
|
|
45
|
+
return (0, client_1.request)('GET', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}/logs${query}`, apiKey);
|
|
46
|
+
}
|
package/dist/hq.d.ts
CHANGED
|
@@ -114,6 +114,18 @@ export declare function getBillingHistory(apiKey: string): Promise<{
|
|
|
114
114
|
status: string;
|
|
115
115
|
created_at: string;
|
|
116
116
|
}[]>;
|
|
117
|
+
export interface ServiceUsage {
|
|
118
|
+
service: string;
|
|
119
|
+
requests: number;
|
|
120
|
+
cost_display: string;
|
|
121
|
+
}
|
|
122
|
+
export interface BillingUsage {
|
|
123
|
+
period: 'month' | '30d';
|
|
124
|
+
since: string;
|
|
125
|
+
services: ServiceUsage[];
|
|
126
|
+
total_display: string;
|
|
127
|
+
}
|
|
128
|
+
export declare function getBillingUsage(apiKey: string, period?: 'month' | '30d'): Promise<BillingUsage>;
|
|
117
129
|
export declare function setupPayment(apiKey: string): Promise<{
|
|
118
130
|
url: string;
|
|
119
131
|
}>;
|
package/dist/hq.js
CHANGED
|
@@ -22,6 +22,7 @@ exports.updateOrg = updateOrg;
|
|
|
22
22
|
exports.deleteOrg = deleteOrg;
|
|
23
23
|
exports.getBalance = getBalance;
|
|
24
24
|
exports.getBillingHistory = getBillingHistory;
|
|
25
|
+
exports.getBillingUsage = getBillingUsage;
|
|
25
26
|
exports.setupPayment = setupPayment;
|
|
26
27
|
exports.topUp = topUp;
|
|
27
28
|
const client_1 = require("./client");
|
|
@@ -48,6 +49,7 @@ exports.EXPOSES = [
|
|
|
48
49
|
'POST /hq/org-imports/{import_id}/confirm',
|
|
49
50
|
'GET /hq/billing/balance',
|
|
50
51
|
'GET /hq/billing/history',
|
|
52
|
+
'GET /hq/billing/usage',
|
|
51
53
|
'POST /hq/billing/setup-payment',
|
|
52
54
|
'POST /hq/billing/topup',
|
|
53
55
|
];
|
|
@@ -139,6 +141,12 @@ async function getBalance(apiKey) {
|
|
|
139
141
|
async function getBillingHistory(apiKey) {
|
|
140
142
|
return (0, client_1.request)('GET', `${config_1.HQ_BASE}/hq/billing/history`, apiKey);
|
|
141
143
|
}
|
|
144
|
+
// getBillingUsage rolls up spend by service for a window: the current
|
|
145
|
+
// calendar month (default) or the trailing 30 days ('30d').
|
|
146
|
+
async function getBillingUsage(apiKey, period) {
|
|
147
|
+
const query = period ? `?period=${encodeURIComponent(period)}` : '';
|
|
148
|
+
return (0, client_1.request)('GET', `${config_1.HQ_BASE}/hq/billing/usage${query}`, apiKey);
|
|
149
|
+
}
|
|
142
150
|
async function setupPayment(apiKey) {
|
|
143
151
|
return (0, client_1.request)('POST', `${config_1.HQ_BASE}/hq/billing/setup-payment`, apiKey);
|
|
144
152
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.payments = exports.fn = exports.crm = exports.database = exports.llm = exports.audience = exports.company = exports.people = exports.url = exports.workflow = exports.webhook = exports.storage = exports.pixel = exports.image = exports.funnel = exports.email = exports.domain = exports.hq = void 0;
|
|
39
|
+
exports.container = exports.payments = exports.fn = exports.crm = exports.database = exports.llm = exports.audience = exports.company = exports.people = exports.url = exports.workflow = exports.webhook = exports.storage = exports.pixel = exports.image = exports.funnel = exports.email = exports.domain = exports.hq = void 0;
|
|
40
40
|
__exportStar(require("./types"), exports);
|
|
41
41
|
__exportStar(require("./client"), exports);
|
|
42
42
|
// Note: config constants (STORAGE_BASE etc.) are NOT re-exported from the
|
|
@@ -63,3 +63,4 @@ exports.database = __importStar(require("./database"));
|
|
|
63
63
|
exports.crm = __importStar(require("./crm"));
|
|
64
64
|
exports.fn = __importStar(require("./function"));
|
|
65
65
|
exports.payments = __importStar(require("./payments"));
|
|
66
|
+
exports.container = __importStar(require("./container"));
|
package/dist/services.js
CHANGED
|
@@ -143,7 +143,9 @@ exports.SERVICES = [
|
|
|
143
143
|
{
|
|
144
144
|
module: 'crm',
|
|
145
145
|
skill: 'my-crm-api',
|
|
146
|
-
domain
|
|
146
|
+
// Brand domain — mycrmapi.com was unavailable; mypipelineapi.com chosen
|
|
147
|
+
// and acquired. (Skill stays my-crm-api — domain/skill mismatch accepted.)
|
|
148
|
+
domain: 'mypipelineapi.com',
|
|
147
149
|
description: 'The canonical store of engaged people + companies. Auto-ingest from inbound webhooks (configurable dot-path). Fixed lifecycle_stage enum, soft delete, event timeline.',
|
|
148
150
|
category: 'data',
|
|
149
151
|
status: 'ga',
|
|
@@ -218,4 +220,20 @@ exports.SERVICES = [
|
|
|
218
220
|
status: 'preview',
|
|
219
221
|
keywords: k('payments', 'stripe', 'checkout', 'billing', 'subscription'),
|
|
220
222
|
},
|
|
223
|
+
{
|
|
224
|
+
// CLI top-level command + SDK namespace are both `container`; skill
|
|
225
|
+
// directory is `my-container-api`.
|
|
226
|
+
//
|
|
227
|
+
// Backend status: Phase 1 shipped (metadata + scoped API key). The
|
|
228
|
+
// Cloud Run build/deploy pipeline is Phase 2 — deploy returns
|
|
229
|
+
// RUNTIME_UNAVAILABLE until it lands. 'preview' reflects "usable
|
|
230
|
+
// surface, deploy not yet GA."
|
|
231
|
+
module: 'container',
|
|
232
|
+
skill: 'my-container-api',
|
|
233
|
+
domain: 'mycontainerapi.com',
|
|
234
|
+
description: 'Run containers on demand — long-running services, background workers, and scheduled jobs. The heavier-duty sibling of edge functions, for native deps and long execution.',
|
|
235
|
+
category: 'compute',
|
|
236
|
+
status: 'preview',
|
|
237
|
+
keywords: k('container', 'cloud-run', 'service', 'worker', 'job'),
|
|
238
|
+
},
|
|
221
239
|
];
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -16,6 +16,7 @@ export const FUNNEL_BASE = process.env.MYAPI_FUNNEL_URL ?? 'https://api.myfunn
|
|
|
16
16
|
// (mirrors the LLM/DATABASE/CRM pattern below).
|
|
17
17
|
export const FUNCTION_BASE= process.env.MYAPI_FUNCTION_URL?? GATEWAY;
|
|
18
18
|
export const PAYMENTS_BASE= process.env.MYAPI_PAYMENTS_URL?? GATEWAY;
|
|
19
|
+
export const CONTAINER_BASE=process.env.MYAPI_CONTAINER_URL?? GATEWAY;
|
|
19
20
|
export const IMAGE_BASE = process.env.MYAPI_IMAGE_URL ?? 'https://api.myimageapi.com';
|
|
20
21
|
export const WEBHOOK_BASE = process.env.MYAPI_WEBHOOK_URL ?? 'https://api.mywebhookapi.com';
|
|
21
22
|
export const WORKFLOW_BASE= process.env.MYAPI_WORKFLOW_URL?? 'https://api.myworkflowapi.com';
|
package/src/container.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { request } from './client';
|
|
2
|
+
import { CONTAINER_BASE as BASE_URL } from './config';
|
|
3
|
+
import type { Exposes } from './exposes';
|
|
4
|
+
|
|
5
|
+
// Backend: my-container-api per myapi-hq/internal/routes/container/. Phase 1
|
|
6
|
+
// is metadata + scoped API key issuance; the Cloud Run build/deploy pipeline
|
|
7
|
+
// is Phase 2 — `deployContainer` returns RUNTIME_UNAVAILABLE until it lands.
|
|
8
|
+
export const EXPOSES: Exposes = [
|
|
9
|
+
'POST /container/orgs/{org_id}/containers',
|
|
10
|
+
'GET /container/orgs/{org_id}/containers',
|
|
11
|
+
'GET /container/orgs/{org_id}/containers/{id}',
|
|
12
|
+
'DELETE /container/orgs/{org_id}/containers/{id}',
|
|
13
|
+
'POST /container/orgs/{org_id}/containers/{id}/deploy',
|
|
14
|
+
'GET /container/orgs/{org_id}/containers/{id}/logs',
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
// service = HTTP server, worker = always-on background process, job = runs
|
|
18
|
+
// to completion (the only type that accepts a cron_schedule).
|
|
19
|
+
export type ContainerType = 'service' | 'worker' | 'job';
|
|
20
|
+
|
|
21
|
+
// Mirrors the backend's `Container` struct in crud.go. `url` is empty until
|
|
22
|
+
// the container is deployed.
|
|
23
|
+
export interface Container {
|
|
24
|
+
id: string;
|
|
25
|
+
org_id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
type: ContainerType;
|
|
28
|
+
cron_schedule?: string;
|
|
29
|
+
env: Record<string, unknown>;
|
|
30
|
+
cpu: string;
|
|
31
|
+
memory: string;
|
|
32
|
+
min_instances: number;
|
|
33
|
+
max_instances: number;
|
|
34
|
+
port: number;
|
|
35
|
+
url?: string;
|
|
36
|
+
status: string;
|
|
37
|
+
created_at: string;
|
|
38
|
+
updated_at: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface CreatePayload {
|
|
42
|
+
name: string; // required; ^[a-z0-9][a-z0-9-]{0,49}$
|
|
43
|
+
type?: ContainerType; // defaults to 'service' server-side
|
|
44
|
+
cron_schedule?: string; // only valid when type is 'job'
|
|
45
|
+
env?: Record<string, unknown>;
|
|
46
|
+
cpu?: string; // defaults to '1'
|
|
47
|
+
memory?: string; // defaults to '512Mi'
|
|
48
|
+
min_instances?: number; // defaults to 0 ('worker' is forced to >= 1)
|
|
49
|
+
max_instances?: number; // defaults to 3
|
|
50
|
+
port?: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// POST response — the scoped API key is returned ONCE. It is delivered to
|
|
54
|
+
// the running container as the MYAPI_KEY environment variable.
|
|
55
|
+
export interface CreateResponse {
|
|
56
|
+
container: Container;
|
|
57
|
+
scoped_api_key: string;
|
|
58
|
+
scoped_api_key_id: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// deployContainer response. The scoped key is ROTATED on every deploy — the
|
|
62
|
+
// value here is fresh and the only time it is knowable.
|
|
63
|
+
export interface DeployResponse {
|
|
64
|
+
container_id: string;
|
|
65
|
+
revision_id: string;
|
|
66
|
+
url: string;
|
|
67
|
+
status: string;
|
|
68
|
+
scoped_api_key: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function createContainer(apiKey: string, orgId: string, payload: CreatePayload): Promise<CreateResponse> {
|
|
72
|
+
return request('POST', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers`, apiKey, payload);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export async function listContainers(apiKey: string, orgId: string): Promise<Container[]> {
|
|
76
|
+
return request('GET', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers`, apiKey);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function getContainer(apiKey: string, orgId: string, containerId: string): Promise<Container> {
|
|
80
|
+
return request('GET', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}`, apiKey);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export async function deleteContainer(apiKey: string, orgId: string, containerId: string): Promise<void> {
|
|
84
|
+
return request('DELETE', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}`, apiKey);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// deployContainer ships a revision from a pre-built image ref to Cloud Run
|
|
88
|
+
// (source builds land in a later backend slice). Rotates the scoped key.
|
|
89
|
+
export async function deployContainer(apiKey: string, orgId: string, containerId: string, image: string): Promise<DeployResponse> {
|
|
90
|
+
return request('POST', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}/deploy`, apiKey, { image });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// One runtime log line from the container's Cloud Run resource.
|
|
94
|
+
export interface LogEntry {
|
|
95
|
+
timestamp: string;
|
|
96
|
+
severity: string;
|
|
97
|
+
text: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// getContainerLogs returns recent runtime log entries, newest first.
|
|
101
|
+
// `tail` caps the count (default 100, max 1000 server-side). An
|
|
102
|
+
// undeployed container returns an empty array.
|
|
103
|
+
export async function getContainerLogs(apiKey: string, orgId: string, containerId: string, tail?: number): Promise<LogEntry[]> {
|
|
104
|
+
const query = tail ? `?tail=${encodeURIComponent(String(tail))}` : '';
|
|
105
|
+
return request('GET', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}/logs${query}`, apiKey);
|
|
106
|
+
}
|
package/src/hq.ts
CHANGED
|
@@ -24,6 +24,7 @@ export const EXPOSES: Exposes = [
|
|
|
24
24
|
'POST /hq/org-imports/{import_id}/confirm',
|
|
25
25
|
'GET /hq/billing/balance',
|
|
26
26
|
'GET /hq/billing/history',
|
|
27
|
+
'GET /hq/billing/usage',
|
|
27
28
|
'POST /hq/billing/setup-payment',
|
|
28
29
|
'POST /hq/billing/topup',
|
|
29
30
|
];
|
|
@@ -233,6 +234,29 @@ export async function getBillingHistory(apiKey: string): Promise<{ type: string;
|
|
|
233
234
|
return request('GET', `${BASE_URL}/hq/billing/history`, apiKey);
|
|
234
235
|
}
|
|
235
236
|
|
|
237
|
+
// One service's rolled-up spend over the usage window.
|
|
238
|
+
export interface ServiceUsage {
|
|
239
|
+
service: string;
|
|
240
|
+
requests: number;
|
|
241
|
+
cost_display: string;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Spend rolled up by service — the accurate "where is my money going" view.
|
|
245
|
+
// Aggregates every billing event, unlike the flat/capped history log.
|
|
246
|
+
export interface BillingUsage {
|
|
247
|
+
period: 'month' | '30d';
|
|
248
|
+
since: string;
|
|
249
|
+
services: ServiceUsage[];
|
|
250
|
+
total_display: string;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// getBillingUsage rolls up spend by service for a window: the current
|
|
254
|
+
// calendar month (default) or the trailing 30 days ('30d').
|
|
255
|
+
export async function getBillingUsage(apiKey: string, period?: 'month' | '30d'): Promise<BillingUsage> {
|
|
256
|
+
const query = period ? `?period=${encodeURIComponent(period)}` : '';
|
|
257
|
+
return request('GET', `${BASE_URL}/hq/billing/usage${query}`, apiKey);
|
|
258
|
+
}
|
|
259
|
+
|
|
236
260
|
export async function setupPayment(apiKey: string): Promise<{ url: string }> {
|
|
237
261
|
return request('POST', `${BASE_URL}/hq/billing/setup-payment`, apiKey);
|
|
238
262
|
}
|
package/src/index.ts
CHANGED
package/src/services.ts
CHANGED
|
@@ -171,7 +171,9 @@ export const SERVICES: readonly ServiceMeta[] = [
|
|
|
171
171
|
{
|
|
172
172
|
module: 'crm',
|
|
173
173
|
skill: 'my-crm-api',
|
|
174
|
-
domain
|
|
174
|
+
// Brand domain — mycrmapi.com was unavailable; mypipelineapi.com chosen
|
|
175
|
+
// and acquired. (Skill stays my-crm-api — domain/skill mismatch accepted.)
|
|
176
|
+
domain: 'mypipelineapi.com',
|
|
175
177
|
description: 'The canonical store of engaged people + companies. Auto-ingest from inbound webhooks (configurable dot-path). Fixed lifecycle_stage enum, soft delete, event timeline.',
|
|
176
178
|
category: 'data',
|
|
177
179
|
status: 'ga',
|
|
@@ -248,4 +250,20 @@ export const SERVICES: readonly ServiceMeta[] = [
|
|
|
248
250
|
status: 'preview',
|
|
249
251
|
keywords: k('payments', 'stripe', 'checkout', 'billing', 'subscription'),
|
|
250
252
|
},
|
|
253
|
+
{
|
|
254
|
+
// CLI top-level command + SDK namespace are both `container`; skill
|
|
255
|
+
// directory is `my-container-api`.
|
|
256
|
+
//
|
|
257
|
+
// Backend status: Phase 1 shipped (metadata + scoped API key). The
|
|
258
|
+
// Cloud Run build/deploy pipeline is Phase 2 — deploy returns
|
|
259
|
+
// RUNTIME_UNAVAILABLE until it lands. 'preview' reflects "usable
|
|
260
|
+
// surface, deploy not yet GA."
|
|
261
|
+
module: 'container',
|
|
262
|
+
skill: 'my-container-api',
|
|
263
|
+
domain: 'mycontainerapi.com',
|
|
264
|
+
description: 'Run containers on demand — long-running services, background workers, and scheduled jobs. The heavier-duty sibling of edge functions, for native deps and long execution.',
|
|
265
|
+
category: 'compute',
|
|
266
|
+
status: 'preview',
|
|
267
|
+
keywords: k('container', 'cloud-run', 'service', 'worker', 'job'),
|
|
268
|
+
},
|
|
251
269
|
] as const;
|