@myapihq/sdk 1.2.6 → 1.2.7

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 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,48 @@
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>;
@@ -0,0 +1,37 @@
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
+ const client_1 = require("./client");
10
+ const config_1 = require("./config");
11
+ // Backend: my-container-api per myapi-hq/internal/routes/container/. Phase 1
12
+ // is metadata + scoped API key issuance; the Cloud Run build/deploy pipeline
13
+ // is Phase 2 — `deployContainer` returns RUNTIME_UNAVAILABLE until it lands.
14
+ exports.EXPOSES = [
15
+ 'POST /container/orgs/{org_id}/containers',
16
+ 'GET /container/orgs/{org_id}/containers',
17
+ 'GET /container/orgs/{org_id}/containers/{id}',
18
+ 'DELETE /container/orgs/{org_id}/containers/{id}',
19
+ 'POST /container/orgs/{org_id}/containers/{id}/deploy',
20
+ ];
21
+ async function createContainer(apiKey, orgId, payload) {
22
+ return (0, client_1.request)('POST', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers`, apiKey, payload);
23
+ }
24
+ async function listContainers(apiKey, orgId) {
25
+ return (0, client_1.request)('GET', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers`, apiKey);
26
+ }
27
+ async function getContainer(apiKey, orgId, containerId) {
28
+ return (0, client_1.request)('GET', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}`, apiKey);
29
+ }
30
+ async function deleteContainer(apiKey, orgId, containerId) {
31
+ return (0, client_1.request)('DELETE', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}`, apiKey);
32
+ }
33
+ // deployContainer ships a revision from a pre-built image ref to Cloud Run
34
+ // (source builds land in a later backend slice). Rotates the scoped key.
35
+ async function deployContainer(apiKey, orgId, containerId, image) {
36
+ return (0, client_1.request)('POST', `${config_1.CONTAINER_BASE}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}/deploy`, apiKey, { image });
37
+ }
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
@@ -18,3 +18,4 @@ export * as database from './database';
18
18
  export * as crm from './crm';
19
19
  export * as fn from './function';
20
20
  export * as payments from './payments';
21
+ export * as container from './container';
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: 'mycrmapi.com',
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@myapihq/sdk",
3
3
  "license": "Apache-2.0",
4
- "version": "1.2.6",
4
+ "version": "1.2.7",
5
5
  "description": "TypeScript SDK for the MyAPI ecosystem",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
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';
@@ -0,0 +1,90 @@
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
+ ];
15
+
16
+ // service = HTTP server, worker = always-on background process, job = runs
17
+ // to completion (the only type that accepts a cron_schedule).
18
+ export type ContainerType = 'service' | 'worker' | 'job';
19
+
20
+ // Mirrors the backend's `Container` struct in crud.go. `url` is empty until
21
+ // the container is deployed.
22
+ export interface Container {
23
+ id: string;
24
+ org_id: string;
25
+ name: string;
26
+ type: ContainerType;
27
+ cron_schedule?: string;
28
+ env: Record<string, unknown>;
29
+ cpu: string;
30
+ memory: string;
31
+ min_instances: number;
32
+ max_instances: number;
33
+ port: number;
34
+ url?: string;
35
+ status: string;
36
+ created_at: string;
37
+ updated_at: string;
38
+ }
39
+
40
+ export interface CreatePayload {
41
+ name: string; // required; ^[a-z0-9][a-z0-9-]{0,49}$
42
+ type?: ContainerType; // defaults to 'service' server-side
43
+ cron_schedule?: string; // only valid when type is 'job'
44
+ env?: Record<string, unknown>;
45
+ cpu?: string; // defaults to '1'
46
+ memory?: string; // defaults to '512Mi'
47
+ min_instances?: number; // defaults to 0 ('worker' is forced to >= 1)
48
+ max_instances?: number; // defaults to 3
49
+ port?: number;
50
+ }
51
+
52
+ // POST response — the scoped API key is returned ONCE. It is delivered to
53
+ // the running container as the MYAPI_KEY environment variable.
54
+ export interface CreateResponse {
55
+ container: Container;
56
+ scoped_api_key: string;
57
+ scoped_api_key_id: string;
58
+ }
59
+
60
+ // deployContainer response. The scoped key is ROTATED on every deploy — the
61
+ // value here is fresh and the only time it is knowable.
62
+ export interface DeployResponse {
63
+ container_id: string;
64
+ revision_id: string;
65
+ url: string;
66
+ status: string;
67
+ scoped_api_key: string;
68
+ }
69
+
70
+ export async function createContainer(apiKey: string, orgId: string, payload: CreatePayload): Promise<CreateResponse> {
71
+ return request('POST', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers`, apiKey, payload);
72
+ }
73
+
74
+ export async function listContainers(apiKey: string, orgId: string): Promise<Container[]> {
75
+ return request('GET', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers`, apiKey);
76
+ }
77
+
78
+ export async function getContainer(apiKey: string, orgId: string, containerId: string): Promise<Container> {
79
+ return request('GET', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}`, apiKey);
80
+ }
81
+
82
+ export async function deleteContainer(apiKey: string, orgId: string, containerId: string): Promise<void> {
83
+ return request('DELETE', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}`, apiKey);
84
+ }
85
+
86
+ // deployContainer ships a revision from a pre-built image ref to Cloud Run
87
+ // (source builds land in a later backend slice). Rotates the scoped key.
88
+ export async function deployContainer(apiKey: string, orgId: string, containerId: string, image: string): Promise<DeployResponse> {
89
+ return request('POST', `${BASE_URL}/container/orgs/${encodeURIComponent(orgId)}/containers/${encodeURIComponent(containerId)}/deploy`, apiKey, { image });
90
+ }
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
@@ -24,3 +24,4 @@ export * as database from './database';
24
24
  export * as crm from './crm';
25
25
  export * as fn from './function';
26
26
  export * as payments from './payments';
27
+ export * as container from './container';
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: 'mycrmapi.com',
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;